PostgreSQL查询每个表大小的方法-创新互联
创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!
多端合一响应式网站:PC+平板+手机,同一后台修改数据多端同步更新提交您的需求,获取网站建设与营销策划方案报价,我们会在1小时内与您联系!小编给大家分享一下PostgreSQL查询每个表大小的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!
PostgreSQL如何查询每个表的大小
1、查询数据库中单个表的大小(不包含索引)
select pg_size_pretty(pg_relation_size('表名'));
2、查询所有表的大小并排序(包含索引)
推荐:postgresql教程
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 20
3、查询表大小按大小排序并分离data与index
SELECT table_name, pg_size_pretty(table_size) AS table_size, pg_size_pretty(indexes_size) AS indexes_size, pg_size_pretty(total_size) AS total_size FROM ( SELECT table_name, pg_table_size(table_name) AS table_size, pg_indexes_size(table_name) AS indexes_size, pg_total_relation_size(table_name) AS total_size FROM ( SELECT ('"' || table_schema || '"."' || table_name || '"') AS table_name FROM information_schema.tables ) AS all_tables ORDER BY total_size DESC ) AS pretty_sizes
看完了这篇文章,相信你对PostgreSQL查询每个表大小的方法有了一定的了解,想了解更多相关知识,欢迎关注创新互联-成都网站建设公司行业资讯频道,感谢各位的阅读!
分享文章:PostgreSQL查询每个表大小的方法-创新互联
网页路径:http://pwwzsj.com/article/dgpeei.html