postgres数据库 查看数据表大小

1 查看某个数据库大小

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

2 查看多个数据库大小

select pg_database.datname, 
	   pg_size_pretty (pg_database_size(pg_database.datname)) 
AS size 
from pg_database; 

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;

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;

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;

你可能感兴趣的:(linux,pgsql,数据库,postgresql)