重庆思庄Oracle、KingBase、PostgreSQL、Redhat认证学习论坛

标题: 通过SQL查询查看pg_tables中每个表的大小(包括数据和索引) [打印本页]

作者: jiawang    时间: 2025-9-4 09:56
标题: 通过SQL查询查看pg_tables中每个表的大小(包括数据和索引)
SELECT
    tablename,
    pg_size_pretty(pg_total_relation_size(quote_ident(schemaname) || '.' || quote_ident(tablename))) AS total_size
FROM
    pg_tables
WHERE
    schemaname NOT IN ('pg_catalog', 'information_schema')
ORDER BY
    pg_total_relation_size(quote_ident(schemaname) || '.' || quote_ident(tablename)) DESC;
4696868b8f11b63d33.png
登录/注册后可看大图