DWS表占用空间查询

发布时间 2023-06-15 17:33:42作者: 迎风2023
1 --查看表占空间使用情况
2 select ns.nspname || '.' || c.relname as table_name, pg_size_pretty(pg_table_size(table_name)) table_size 
3 from pg_class c join pg_namespace ns on ( ns.oid = c.relnamespace ) left join pgxc_class pc on ( c.oid = pc.pcrelid ) 
4 where pc.pclocatortype <> 'N' AND ns.nspname NOT IN ('pg_toast', 'pg_catalog', 'information_schema', 'cstore', 'pmk') 
5 AND c.relkind = 'r' AND c.oid > 16384 order by table_size desc;

 效果: