SELECTn.nspname AS schema_name,c.relname AS table_name,-- 1️⃣ 总大小(表 + toast + 索引)pg_size_pretty(pg_total_relation_size(c.oid)) AS total_size,-- 2️⃣ 表不包含索引(含 TOAST)pg_size_pretty(pg_total_relation_size(c.oid) - pg_indexes_size(c.oid)) AS without_index_size,-- 3️⃣ 仅表本体(不含 TOAST、不含索引)pg_size_pretty(pg_relation_size(c.oid)) AS table_only_size,-- 4️⃣ 索引大小(不含 TOAST)pg_size_pretty(pg_indexes_size(c.oid)) AS index_sizeFROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind = 'r' -- 普通表AND n.nspname NOT IN ('pg_catalog', 'information_schema')
-- AND c.relname = 'appraisal_history_sales'
ORDER BY pg_total_relation_size(c.oid) DESC;
返回结果