2018-07-17

postgre 查看表所占空间大小

方法一 ,查一个表

select pg_size_pretty(pg_relation_size('table_name'));

1

方法二 ,查出所有表并按大小排序

SELECT

table_schema || '.' || table_name

AS table_full_name, pg_size_pretty(pg_total_relation_size('"' ||table_schema || '"."' || table_name || '"')) AS size

FROM

information_schema.tables

ORDER BY

    pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')

DESC limit 200

你可能感兴趣的:(2018-07-17)