@@ -966,34 +966,33 @@ metrics:
966
966
- wal_bytes
967
967
- temp_bytes_read
968
968
- temp_bytes_written
969
- pg_index_tuples :
969
+ pg_class :
970
970
description : >
971
- Track tuple counts (live, dead, and total) for indexes using reltuples from pg_class .
972
- This metric provides insights into index tuple distribution and can help identify
973
- indexes that may benefit from maintenance operations .
971
+ Direct access to pg_class system catalog data for all relations (tables, indexes, etc) .
972
+ Provides reltuples, relpages, and other pg_class columns with relname and schemaname
973
+ as tags for easy filtering and querying .
974
974
sqls :
975
975
11 : |
976
976
select
977
977
current_database() as tag_datname,
978
978
n.nspname as tag_schemaname,
979
- t.relname as tag_tablename,
980
- i.relname as tag_indexname,
981
- i.reltuples as total_tuples,
982
- coalesce(pg_stat_get_live_tuples(t.oid), 0) as live_tuples,
983
- coalesce(pg_stat_get_dead_tuples(t.oid), 0) as dead_tuples
984
- from pg_class i
985
- join pg_index idx on idx.indexrelid = i.oid
986
- join pg_class t on t.oid = idx.indrelid
987
- join pg_namespace n on n.oid = i.relnamespace
988
- where i.relkind = 'i'
989
- and t.relkind = 'r'
990
- and n.nspname not in ('information_schema', 'pg_catalog')
991
- order by i.reltuples desc nulls last
992
- limit 5000
979
+ c.relname as tag_relname,
980
+ c.relkind as tag_relkind,
981
+ c.reltuples,
982
+ c.relpages,
983
+ pg_relation_size(c.oid) as relation_size_bytes,
984
+ pg_total_relation_size(c.oid) as total_relation_size_bytes
985
+ from pg_class c
986
+ join pg_namespace n on n.oid = c.relnamespace
987
+ where n.nspname not in ('information_schema', 'pg_catalog')
988
+ and c.relkind in ('r', 'i', 'm', 'v') -- tables, indexes, materialized views, views
989
+ order by pg_total_relation_size(c.oid) desc
990
+ limit 10000
993
991
gauges :
994
- - total_tuples
995
- - live_tuples
996
- - dead_tuples
992
+ - reltuples
993
+ - relpages
994
+ - relation_size_bytes
995
+ - total_relation_size_bytes
997
996
pg_stat_user_indexes :
998
997
sqls :
999
998
11 : |
@@ -1985,7 +1984,7 @@ presets:
1985
1984
pg_stat_wal_receiver : 30
1986
1985
pg_archiver : 30
1987
1986
pg_stat_user_tables : 30
1988
- pg_index_tuples : 30
1987
+ pg_class : 30
1989
1988
pg_stat_user_indexes : 30
1990
1989
pg_stat_statements : 30
1991
1990
pg_stat_replication : 30
0 commit comments