Skip to content

Instantly share code, notes, and snippets.

@dlundy
Created September 30, 2014 22:53
Show Gist options
  • Save dlundy/3437e4b58cae355bfddd to your computer and use it in GitHub Desktop.
Save dlundy/3437e4b58cae355bfddd to your computer and use it in GitHub Desktop.
get table sizes in postgres
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
where relname like {{table_name}}
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