Created
October 26, 2017 13:05
-
-
Save olooney/d0ee0e46e929d65b9056cc6210cc97f9 to your computer and use it in GitHub Desktop.
find large tables and convert them to compressed tables in Greenplum
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 | |
sum(size) AS total_size_on_disk, | |
sum(size) / (select count(*) from individual) AS per_individual | |
FROM ( | |
SELECT | |
pg_relation_size(C.oid) AS "size" | |
FROM pg_class C | |
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) | |
WHERE 1=1 -- relname in (...) | |
ORDER BY pg_relation_size(C.oid) DESC | |
) table_sizes; | |
create table xxx_zlib with (appendonly=true, compresstype=zlib, compresslevel=6) as (select * from xxx) distributed by (pkcol1, ...); | |
drop table xxx; | |
alter table xxx_zlib rename to xxx; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment