Skip to content

Instantly share code, notes, and snippets.

@zeppelinen
Created April 10, 2019 09:23
Show Gist options
  • Save zeppelinen/567d3c882e1d72f1a7f294b539975220 to your computer and use it in GitHub Desktop.
Save zeppelinen/567d3c882e1d72f1a7f294b539975220 to your computer and use it in GitHub Desktop.
Show table sizes of PostgreSQL database
SELECT
relname as "Table",
pg_size_pretty(pg_total_relation_size(relid)) As "Size",
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size"
FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment