[PostgreSQL] 統計SQL記錄


1.列出前十筆最大的Table:

SELECT N.nspname || '.' || C.relname AS "table", pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema','pg_toast')
ORDER BY pg_relation_size(C.oid) DESC LIMIT 10;