Created
December 31, 2016 14:55
-
-
Save kerbelp/3b4f6b6bccba0dd99c36aa7694ab88d6 to your computer and use it in GitHub Desktop.
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
SELECT TRIM(pgdb.datname) AS DATABASE, | |
TRIM(pgn.nspname) AS SCHEMA, | |
TRIM(a.name) AS TABLE, | |
b.mbytes, | |
a.rows | |
FROM (SELECT db_id, | |
id, | |
name, | |
SUM(ROWS) AS ROWS | |
FROM stv_tbl_perm a | |
GROUP BY db_id, | |
id, | |
name) AS a | |
JOIN pg_class AS pgc ON pgc.oid = a.id | |
JOIN pg_namespace AS pgn ON pgn.oid = pgc.relnamespace | |
JOIN pg_database AS pgdb ON pgdb.oid = a.db_id | |
JOIN (SELECT tbl, COUNT(*) AS mbytes FROM stv_blocklist GROUP BY tbl) b ON a.id = b.tbl | |
ORDER BY mbytes DESC, | |
a.db_id, | |
a.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment