select pg_database.datname,
pg_size_pretty (pg_database_size(pg_database.datname))AS size
from pg_database;
3 View the index in order
select indexrelname, pg_size_pretty(pg_relation_size(relid))from pg_stat_user_indexes
where schemaname='public'orderby pg_relation_size(relid)desc;
4 View the size of all tables
select relname, pg_size_pretty(pg_relation_size(relid))from pg_stat_user_tables
where schemaname='public'orderby pg_relation_size(relid)desc;
5 View the size of a specific table
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;