当前位置:   article > 正文

查看postgresql某张表的占用空间_pg怎么看数据库某个表占用的内存

pg怎么看数据库某个表占用的内存

@查看postgresql的占用空间

查看postgresql某张表的占用空间

select relpages*8/1024||'M' as 占用空间,reltuples 记录数 from pg_class where relname='表名';
  • 1

查看postgresql某个数据库的占用空间(不写where条件是查询所有数据库)

 select pg_database.datname, pg_size_pretty (pg_database_size(pg_database.datname)) AS size 
  from pg_database WHERE pg_database.datname = '指定的库名称'
  • 1
  • 2

查看postgresql某数据库下按占用空间排序(从大大小)

 SELECT table_schema || '.' || table_name AS table_full_name, pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')AS size
FROM information_schema.tables WHERE table_schema = 'public'
ORDER BY
pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') DESC
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/266640
推荐阅读
相关标签
  

闽ICP备14008679号