GP - SQL to gather all the relations and sorts the objects with highest size.
TOP 10 - Relation size in the database - Index inclusive
SELECT
nspname ||'.'|| relname AS "Relation Name",
nspname AS "Schema Name",
case relkind when 'r' then 'Table'
when 'i' then 'Index'
when 'S' then 'Sequence'
when 't' then 'Toast Table'
when 'v' then 'View'
when 'c' then 'Composite Type'
when 'o' then 'Append-only Tables'
when 's' then 'Special'
end AS "Object Type",
pg_size_pretty(pg_total_relation_size(a.oid)) AS "size"
FROM
pg_class a ,
pg_namespace b
WHERE
b.oid = a.relnamespace
AND nspname NOT IN ('pg_catalog', 'information_schema')
AND a.relkind!='i'
AND b.nspname !~ '^pg_toast'
ORDER BY pg_total_relation_size(a.oid) DESC
LIMIT 10;
Comments
Post a Comment