Updated on 2024-12-19 GMT+08:00

PG_STAT_ALL_TABLES

PG_STAT_ALL_TABLES displays statistics about accesses to tables in the current database, including TOAST tables.

Table 1 PG_STAT_ALL_TABLES columns

Name

Type

Description

relid

oid

Table OID

schemaname

name

Schema name of the table

relname

name

Name of the table

seq_scan

bigint

Number of sequential scans started on the table

seq_tup_read

bigint

Number of rows that have live data fetched by sequential scans

idx_scan

bigint

Number of index scans

idx_tup_fetch

bigint

Number of rows that have live data fetched by index scans

n_tup_ins

bigint

Number of rows inserted

n_tup_upd

bigint

Number of rows updated

n_tup_del

bigint

Number of rows deleted

n_tup_hot_upd

bigint

Number of rows updated by HOT (no separate index update is required)

n_live_tup

bigint

Estimated number of live rows

n_dead_tup

bigint

Estimated number of dead rows

last_vacuum

timestamp with time zone

Last time at which this table was manually vacuumed (excluding VACUUM FULL)

last_autovacuum

timestamp with time zone

Last time at which this table was automatically vacuumed

last_analyze

timestamp with time zone

Last time at which this table was analyzed

last_autoanalyze

timestamp with time zone

Last time at which this table was automatically vacuumed

vacuum_count

bigint

Number of vacuum operations (excluding VACUUM FULL)

autovacuum_count

bigint

Number of autovacuum operations

analyze_count

bigint

Number of analyze operations

autoanalyze_count

bigint

Number of autoanalyze operations

last_data_changed

timestamp with time zone

Last time at which this table was updated (by INSERT/UPDATE/DELETE or EXCHANGE/TRUNCATE/DROP partition). This column is recorded only on the local CN.

Example

Query the last data change time in the table_test table:

1
2
3
4
5
SELECT last_data_changed FROM PG_STAT_ALL_TABLES WHERE relname ='table_test';
       last_data_changed
-------------------------------
 2024-03-27 10:28:16.277136+08
(1 row)