博主头像
7024w的自留地

觉宇宙之无穷,识盈虚之有数

查询PostgreSQL数据表占用空间

SELECT 
    relname AS table_name,
    pg_size_pretty(pg_relation_size(relid)) AS data_size,
    pg_size_pretty(pg_indexes_size(relid)) AS index_size,
    pg_size_pretty(pg_total_relation_size(relid)) AS total_size
FROM pg_catalog.pg_statio_user_tables
ORDER BY pg_total_relation_size(relid) DESC;
发表新评论