我每周在 Postgres上遇到这个查询,它显示了表格、它们的大小、toast 大小和索引大小(以字节为单位):
SELECT
relname AS table_name,
pg_size_pretty(pg_total_relation_size(relid)) AS total,
pg_size_pretty(pg_relation_size(relid)) AS internal,
pg_size_pretty(pg_table_size(relid) - pg_relation_size(relid)) AS external,
pg_size_pretty(pg_indexes_size(relid)) AS indexes
FROM pg_catalog.pg_statio_user_tables
ORDER BY pg_total_relation_size(relid) DESC;
我知道 Postgres 正在为每个分区创建一个表,所以我分别为每个分区获取条目,但是有没有办法让每个表有一行,不管这个表是否分区?