Skip to content

Instantly share code, notes, and snippets.

@victorpendleton
Last active November 8, 2019 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorpendleton/0eb4b6191c1c3ff9aac535dbd939ebb7 to your computer and use it in GitHub Desktop.
Save victorpendleton/0eb4b6191c1c3ff9aac535dbd939ebb7 to your computer and use it in GitHub Desktop.
Git size of postgres schemas
SELECT n.nspname
, ROUND(SUM(pg_total_relation_size(c.oid))/1024/1024, 2) AS MB
FROM pg_class c INNER
JOIN pg_namespace n
ON c.relnamespace = n.oid
WHERE relkind = 'r'
AND n.nspname NOT LIKE 'pg%'
GROUP BY 1
ORDER BY 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment