Skip to content

Instantly share code, notes, and snippets.

@letiesperon
Created February 22, 2022 17:59
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 letiesperon/5e6e75a05849c501659a15fb1de3b367 to your computer and use it in GitHub Desktop.
Save letiesperon/5e6e75a05849c501659a15fb1de3b367 to your computer and use it in GitHub Desktop.
SQL query to get the size of all the tables in a database
SELECT
table_name,
pg_size_pretty(pg_total_relation_size(quote_ident(table_name))),
pg_total_relation_size(quote_ident(table_name)) as "Raw size"
FROM information_schema.tables
WHERE table_schema = 'public'
ORDER BY 3 DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment