云数据库 GAUSSDB-PG_STAT_USER_TABLES
PG_STAT_USER_TABLES
PG_STAT_USER_TABLES视图显示所有命名空间中用户自定义普通表和toast表的状态信息。通过该视图查看VACUUM在某张表上的执行情况,通常需要关注n_dead_tup和last_autovacuum字段。字段含义如下:
名称 |
类型 |
描述 |
---|---|---|
relid |
oid |
表的OID。 |
schemaname |
name |
该表的模式名。 |
relname |
name |
表名。 |
seq_scan |
bigint |
该表发起的顺序扫描数。 |
seq_tup_read |
bigint |
顺序扫描抓取的活跃行数。 |
idx_scan |
bigint |
该表发起的索引扫描数。 |
idx_tup_fetch |
bigint |
索引扫描抓取的活跃行数。 |
n_tup_ins |
bigint |
插入行数。 |
n_tup_upd |
bigint |
更新行数。 |
n_tup_del |
bigint |
删除行数。 |
n_tup_hot_upd |
bigint |
HOT更新行数(即没有更新所需的单独索引)。 |
n_live_tup |
bigint |
估计活跃行数。 |
n_dead_tup |
bigint |
估计死行数。 |
last_vacuum |
timestamp with time zone |
最后一次该表是手动清理的(不计算Vacuum Full)。 |
last_autovacuum |
timestamp with time zone |
上次AUTOVACUUM守护进程清理的表。 |
last_analyze |
timestamp with time zone |
上次手动分析这个表。 |
last_autoanalyze |
timestamp with time zone |
上次被AUTOVACUUM守护进程分析的表。 |
vacuum_count |
bigint |
这个表被手动清理的次数(不计算Vacuum Full)。 |
autovacuum_count |
bigint |
这个表被AUTOVACUUM清理的次数。 |
analyze_count |
bigint |
这个表被手动分析的次数。 |
autoanalyze_count |
bigint |
这个表被AUTOVACUUM守护进程分析的次数。 |
last_data_changed |
timestamp with time zone |
这个表数据最近修改时间。 |
执行示例如下:
gaussdb=# \x Expanded display is on. gaussdb=# select * from pg_stat_user_tables where relname='t2'; -[ RECORD 1 ]-----+------------------------------ relid | 98316 schemaname | public relname | t2 seq_scan | 2 seq_tup_read | 20002 idx_scan | idx_tup_fetch | n_tup_ins | 10001 n_tup_upd | 10001 n_tup_del | 5001 n_tup_hot_upd | 0 n_live_tup | 5000 n_dead_tup | 15002 last_vacuum | 2025-02-09 10:16:47.317412-05 last_autovacuum | 2025-02-09 10:16:47.317412-05 last_analyze | 2025-02-09 10:16:37.491756-05 last_autoanalyze | 2025-02-09 10:16:37.491756-05 vacuum_count | 3 autovacuum_count | 3 analyze_count | 2 autoanalyze_count | 2 last_data_changed | 2025-02-09 10:16:34.660061-05