Skip to content

Instantly share code, notes, and snippets.

@delicb
Last active December 20, 2015 16:38
Show Gist options
  • Save delicb/6162559 to your computer and use it in GitHub Desktop.
Save delicb/6162559 to your computer and use it in GitHub Desktop.
Lists tables and its sizes in postgresql
SELECT
table_schema || '.' || table_name AS table_full_name,
pg_size_pretty(pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')) AS size
FROM information_schema.tables
WHERE table_schema = 'public'
ORDER BY
pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment