Skip to content

Instantly share code, notes, and snippets.

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/c6d26fda13bd0c09bd64dbbaf7ca405e to your computer and use it in GitHub Desktop.
Save victorpendleton/c6d26fda13bd0c09bd64dbbaf7ca405e to your computer and use it in GitHub Desktop.
Get Postgres table size
SELECT n.nspname
, c.relname
, 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 IN ('')
AND c.relname = ''
GROUP BY 1, 2
ORDER BY 3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment