WITH sizes AS (SELECT nspname || '.' || relname AS "relation",
pg_total_relation_size(C.oid) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'
) SELECT pg_size_pretty(SUM(total_size)) FROM sizes;
Created
January 17, 2020 21:38
-
-
Save FragLegs/4c7b60c5e682923101c417a33b71e70d to your computer and use it in GitHub Desktop.
DB scripts
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment