当前位置:   article > 正文

postgres数据库 查看数据表大小_pg查看表大小

pg查看表大小

1 查看某个数据库大小

select pg_database_size('【数据库名】');
  • 1

2 查看多个数据库大小

select pg_database.datname, 
	   pg_size_pretty (pg_database_size(pg_database.datname)) 
AS size 
from pg_database; 
  • 1
  • 2
  • 3
  • 4

3 按顺序查看索引

select indexrelname, pg_size_pretty(pg_relation_size(relid)) 
from pg_stat_user_indexes 
where schemaname='public' 
order by pg_relation_size(relid) desc;
  • 1
  • 2
  • 3
  • 4

4 查看所有表的大小

select relname, pg_size_pretty(pg_relation_size(relid)) 
from pg_stat_user_tables 
where schemaname='public' 
order by pg_relation_size(relid) desc;
  • 1
  • 2
  • 3
  • 4

5 查看特定表的大小

select relname, pg_size_pretty(pg_relation_size(relid)) 
from pg_stat_user_tables 
where schemaname='public' and relname='【表名】'
order by pg_relation_size(relid) desc;
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/222731
推荐阅读
相关标签
  

闽ICP备14008679号