1. PG里如何查看錶,索引,表空間,資料庫大小
--查詢一個索引大小 select pg_size_pretty(pg_relation_size('indexname))--查看一張表及此它上的索引總大小 select pg_size_pretty(pg_total_relation_size('tablename')); --查看所有 schema裡面索引大小,大到小的順序排列: select indexrelname,pg_size_pretty( pg_relation_size(relid)) from pg_stat_user_indexes where schemaname = 'schemaname' order by pg_relation_size(relid) desc;--查看所有 schema裡面表的大小,從大到小順序排列: select relname, pg_size_pretty(pg_relation_size(relid)) from pg_stat_user_tables where schemaname = 'schemaname' order by pg_relation_size(relid) desc; --查看資料庫大小: select pg_database.datname,pg_size_pretty(pg_database_size(pg_database.datname)) AS size from pg_database;--查看錶空間大小