Objects

Updated at:

Query the following views to get access and I/O statistics for database objects in PolarDB for PostgreSQL (Compatible with Oracle). Use this data to identify performance bottlenecks and diagnose issues with tables, indexes, sequences, and functions.

Statistics in these views are not updated in real time. Each server process flushes accumulated statistics to shared memory just before going idle, so the data reflects recent—not current—activity. Queries and transactions still in progress are not included in the displayed totals.

Tables

pg_stat_all_tables

Use pg_stat_all_tables to understand how each table is being accessed—whether rows are retrieved by sequential scans or index scans, and how often rows are inserted, updated, or deleted. This helps identify tables that lack appropriate indexes or need more frequent vacuuming.

ParameterTypeDescription
relidoidThe OID of the table.
schemanamenameThe name of the schema to which the table belongs.
relnamenameThe name of the table.
seq_scanbigintThe number of sequential scans initiated on the table.
seq_tup_readbigintThe number of live rows fetched by sequential scans.
idx_scanbigintThe number of index scans initiated on the table.
idx_tup_fetchbigintThe number of live rows fetched by index scans.
n_tup_insbigintThe number of inserted rows.
n_tup_updbigintThe number of updated rows. This includes the rows that are updated by the Heap Only Tuple (HOT) feature.
n_tup_delbigintThe number of rows deleted from the table.
n_tup_hot_updbigintThe number of rows updated by the HOT feature. The rows are updated without the need to separately update indexes.
n_live_tupbigintThe estimated number of live rows.
n_dead_tupbigintThe estimated number of dead rows.
n_mod_since_analyzebigintThe estimated number of rows that are modified after the table was last analyzed.
last_vacuumtimestamp with time zoneThe latest time when the table was manually vacuumed. The time consumed by the VACUUM FULL statement is not counted.
last_autovacuumtimestamp with time zoneThe latest time when the table was automatically vacuumed by the autovacuum daemon.
last_analyzetimestamp with time zoneThe latest time when the table was manually analyzed.
last_autoanalyzetimestamp with time zoneThe latest time when the table was automatically analyzed by the autovacuum daemon.
vacuum_countbigintThe number of manual VACUUM operations on the table. This value does not include the number of times VACUUM FULL is executed.
autovacuum_countbigintThe number of automatic VACUUM operations on the table by the autovacuum daemon.
analyze_countbigintThe number of manual ANALYZE operations on the table.
autoanalyze_countbigintThe number of automatic ANALYZE operations on the table by the autovacuum daemon.
n_tup_upd counts all updated rows, including HOT updates. n_tup_hot_upd counts only HOT updates—rows updated in place without modifying index entries. A high n_tup_hot_upd relative to n_tup_upd indicates that HOT updates are working efficiently.

pg_statio_all_tables

Use pg_statio_all_tables to determine the effectiveness of the buffer cache for each table. A low cache hit ratio indicates that the database is reading frequently from disk, which can degrade performance.

ParameterTypeDescription
relidoidThe OID of the table.
schemanamenameThe name of the schema to which the table belongs.
relnamenameThe name of the metatable.
heap_blks_readbigintThe number of disk blocks read from the table.
heap_blks_hitbigintThe number of buffer cache hits in the table.
idx_blks_readbigintThe number of disk blocks that are read from all the indexes in the table.
idx_blks_hitbigintThe number of buffer cache hits for all the indexes in the table.
toast_blks_readbigintThe number of disk blocks that are read from the TOAST table associated with the table.
toast_blks_hitbigintThe number of buffer cache hits in the TOAST table associated with the table.
tidx_blks_readbigintThe number of disk blocks that are read from the indexes for the TOAST table associated with the table.
tidx_blks_hitbigintThe number of buffer cache hits for the indexes for the TOAST table associated with the table.

Indexes

pg_stat_all_indexes

Use pg_stat_all_indexes to determine which indexes are being used and how effective they are. Indexes with a low idx_scan count relative to the number of rows in the table may not be worth the overhead.

Indexes can be accessed by simple index scans, bitmap scans, or the query optimizer. In a bitmap scan, output from multiple indexes can be combined using AND or OR rules. Because individual rows in a bitmap scan cannot be associated with specific indexes, a bitmap scan increases idx_tup_read for the participating indexes and increases pg_stat_all_tables.idx_tup_fetch for the table—but does not affect idx_tup_fetch for the indexes themselves. If constant values fall outside the range of optimizer statistics, the optimizer may still access indexes to verify the values.

ParameterTypeDescription
relidoidThe OID of the table for the index.
indexrelidoidThe OID of the index.
schemanamenameThe name of the schema to which the index belongs.
relnamenameThe name of the table for the index.
indexrelnamenameThe name of the index.
idx_scanbigintThe number of scans initiated on the index.
idx_tup_readbigintThe number of index items returned by scans on the index.
idx_tup_fetchbigintThe number of live table rows that simple index scans fetch by using this index.
idx_tup_read and idx_tup_fetch can differ even without bitmap scans. idx_tup_read counts index entries retrieved from the index, while idx_tup_fetch counts live rows fetched from the table. idx_tup_fetch is lower when dead rows or not-yet-committed rows are encountered during the scan, or when index-only scans avoid fetching heap rows entirely.

pg_statio_all_indexes

Use pg_statio_all_indexes to calculate the cache hit ratio for each index. This helps identify indexes that are read from disk frequently, which can slow down query execution.

ParameterTypeDescription
relidoidThe OID of the table for the index.
indexrelidoidThe OID of the index.
schemanamenameThe name of the schema in which the index resides.
relnamenameThe name of the table for the index.
indexrelnamenameThe name of the index.
idx_blks_readbigintThe number of disk blocks read from the index.
idx_blks_hitbigintThe number of buffer cache hits for the index.

Sequences

pg_statio_all_sequences

pg_statio_all_sequences shows I/O statistics for each sequence in the current database. Use it to identify sequences with high disk read counts, which can indicate buffer cache pressure on sequence blocks.

ParameterTypeDescription
relidoidThe OID of the sequence.
schemanamenameThe name of the schema to which the sequence belongs.
relnamenameThe name of the sequence.
blks_readbigintThe number of disk blocks read from the sequence.
blks_hitbigintThe number of buffer cache hits in the sequence.

Functions

pg_stat_user_functions

pg_stat_user_functions shows execution statistics for tracked functions. Use it to identify functions with high call counts or excessive total execution time.

ParameterTypeDescription
funcidoidThe OID of the function.
schemanamenameThe name of the schema to which the function belongs.
funcnamenameThe name of the function.
callsbigintThe number of calls for the function.
total_timedouble precisionThe total time consumed to invoke the function and all functions it calls. Unit: milliseconds.
self_timedouble precisionThe total time consumed to invoke the function, excluding time spent in functions it calls. Unit: milliseconds.