1. 查看
数据库大小。
select pg_size_pretty(pg_database_size('db_name'));
通过 pgAdmin 我们可以看到,在 Postgresql(pg_catalog) 下有如下两个视图:
pg_stat_user_tables,pg_stat_user_indexes。可以通过它们来查看表及索引的大小。
2. 查看所有索引的大小。
select indexrelname,
pg_size_pretty(pg_relation_size(indexrelname))
from pg_stat_user_indexes
where schemaname = 'public'
order by pg_relation_size(indexrelname) desc;
3. 查所有表的大小。
select relname,
pg_size_pretty(pg_relation_size(relname))
from pg_stat_user_tables
where schemaname = 'public'
order by pg_relation_size(relname) desc;
4. 查看单个表的大小。
select pg_size_pretty(pg_relation_size('table_name'));
原文链接:https://www.f2er.com/postgresql/196078.html