偶小梦
发布于

如何查看数据库中索引和表的大小?

➢ 解答
SELECT indexrelid::regclass idx_name,
indrelid::regclass tab_name,
pg_size_pretty(pg_relation_size(indexrelid)) idx_size,
pg_size_pretty(pg_relation_size(indrelid)) tab_size,
(pg_relation_size(indexrelid) - pg_relation_size(indrelid)) size_diff
FROM pg_index
WHERE indrelid IN (SELECT oid FROM pg_class where relnamespace=11)
ORDER BY 5 DESC;

评论
    test