Created
February 22, 2022 17:59
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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