Last active
February 28, 2019 09:19
-
-
Save t0mdicks0n/75057151eccaed9eff20431ff9ae80f0 to your computer and use it in GitHub Desktop.
List disk usage of PSQL instance per table in the schema public
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(t_size) AS size_pretty | |
FROM ( | |
SELECT | |
table_name, | |
pg_relation_size(quote_ident(table_name)) AS t_size | |
FROM information_schema.tables | |
WHERE table_schema = 'public' | |
UNION ALL | |
SELECT | |
'--ALL TABLES--'::text AS table_name, | |
SUM(pg_relation_size(quote_ident(table_name))) AS t_size | |
FROM information_schema.tables | |
WHERE table_schema = 'public' | |
ORDER BY t_size DESC | |
) C; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment