Created
June 17, 2018 16:57
-
-
Save jimcavoli/2fb0ae1349e69cc18ec5bdd7a02a8c3f to your computer and use it in GitHub Desktop.
Handy PostgreSQL maintenance queries
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
-- Lists the size of all relations in the current 'public' schema in descending order | |
SELECT | |
nspname||'.'||relname AS relation, | |
pg_size_pretty(pg_total_relation_size(nspname||'.'||relname)) as pretty_size, | |
pg_total_relation_size(nspname||'.'||relname) as raw_size | |
FROM | |
pg_class, pg_namespace | |
WHERE | |
relnamespace = pg_namespace.oid | |
AND | |
nspname = 'public' | |
ORDER BY | |
raw_size DESC | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment