Created
October 14, 2014 21:00
-
-
Save padak/2f84bcdf7789623f0670 to your computer and use it in GitHub Desktop.
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 | |
CAST(pg_database.datname AS VARCHAR), | |
bytes | |
FROM | |
(SELECT | |
p.db_id, | |
sum(b.blocknum * 1048576) AS bytes | |
FROM pg_catalog.stv_tbl_perm p JOIN (SELECT | |
bl.tbl, | |
bl.slice, | |
count(bl.blocknum) AS blocknum | |
FROM pg_catalog.stv_blocklist bl | |
GROUP BY bl.tbl, bl.slice) b ON b.tbl = p.id AND b.slice = p.slice | |
GROUP BY p.db_id | |
) AS dbsizes | |
JOIN pg_database | |
ON dbsizes.db_id = pg_database.oid | |
ORDER BY bytes DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment