Last active
January 12, 2016 15:47
-
-
Save belsrc/ce45581a06e4f05446e0 to your computer and use it in GitHub Desktop.
Show relation size in Postgres
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
-- Relations, as in, tables and indexes | |
SELECT nspname || '.' || relname AS "relation", | |
pg_size_pretty(pg_relation_size(PC.oid)) AS "size" | |
FROM pg_class PC | |
LEFT JOIN pg_namespace NS ON (NS.oid = PC.relnamespace) | |
WHERE nspname NOT IN ('pg_catalog', 'information_schema') | |
AND nspname !~ '^pg_toast' | |
ORDER BY pg_relation_size(PC.oid) DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment