Skip to content

Instantly share code, notes, and snippets.

@Barathchander
Created March 11, 2019 11:14
Show Gist options
  • Save Barathchander/25c1fed852a415f26c3ee40ad4681cc5 to your computer and use it in GitHub Desktop.
Save Barathchander/25c1fed852a415f26c3ee40ad4681cc5 to your computer and use it in GitHub Desktop.
query to return redshift DB size
select sum(mbytes)/1024, database from (
select trim(pgdb.datname) as Database,
trim(a.name) as Table, b.mbytes
from stv_tbl_perm a
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
where a.slice=0
order by db_id, name)
group by database;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment