Skip to content

Instantly share code, notes, and snippets.

@jorgeas80
Created October 15, 2017 09:17
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 jorgeas80/4d1540a2ec6fb3efb364bb848a72d4ca to your computer and use it in GitHub Desktop.
Save jorgeas80/4d1540a2ec6fb3efb364bb848a72d4ca to your computer and use it in GitHub Desktop.
Get size of database objects
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