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;

--查看表空间大小
select pg_tablespace_size('tbs_index')/1024/1024 as "SIZE M";

上一篇:[转] 2016 JavaScript 发展现状大调查


下一篇:前端随笔 - JavaScript中的闭包