Created
August 15, 2017 02:44
-
-
Save fervic/e9ae3ad07a5856a941ebf3d73ff973c6 to your computer and use it in GitHub Desktop.
Table sizes in Redshift
This file contains hidden or 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
-- Get table sizes in Gigabytes sorted by size descending | |
SELECT name AS "table", substring(datname, 1, 15) AS "database", ROUND((COUNT(*) / 1024.0),2) AS "GB" | |
FROM stv_blocklist | |
INNER JOIN ( | |
SELECT DISTINCT id, name, datname, db_id FROM stv_tbl_perm | |
INNER JOIN pg_database | |
ON stv_tbl_perm.db_id = pg_database.oid | |
) AS t | |
ON t.id = stv_blocklist.tbl | |
GROUP BY name, datname | |
ORDER BY "GB" DESC | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment