Skip to content

Instantly share code, notes, and snippets.

@jonathanvx
Forked from subelsky/large_redshift_tables.sql
Created October 11, 2017 07:34
Show Gist options
  • Save jonathanvx/b749369bec57cb14cf4eda5c12306257 to your computer and use it in GitHub Desktop.
Save jonathanvx/b749369bec57cb14cf4eda5c12306257 to your computer and use it in GitHub Desktop.
Quick SQL command to find large tables in redshift
-- based on http://stackoverflow.com/questions/21767780/how-to-find-size-of-database-schema-table-in-redshift
SELECT name AS table_name, ROUND((COUNT(*) / 1024.0),2) as "Size in Gigabytes"
FROM stv_blocklist
INNER JOIN
(SELECT DISTINCT id, name FROM stv_tbl_perm) names
ON names.id = stv_blocklist.tbl
GROUP BY name
ORDER BY "Size in Gigabytes" DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment