Created
December 11, 2014 01:42
-
-
Save koko1000ban/f5cf372a93ad0b1f596b to your computer and use it in GitHub Desktop.
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
select | |
trim(pgdb.datname) as Database, | |
trim(pgn.nspname) as Schema, | |
trim(a.name) as Table, | |
b.mbytes, | |
(CAST(b.mbytes as double precision) / 1024) as gbytes, | |
(CAST(b.mbytes as double precision) / 1048576) as tbytes, | |
a.rows, | |
to_char(a.rows, '999,999,999,999,999') as rows_ww, | |
to_char(a.rows, '9999,9999,9999,9999') as rows_jp | |
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