cluster an index in Greenplum Database

For very large tables, using the CLUSTER command to physically reorder a table based on an index can take an extremely long time. To achieve the same results much faster, you can manually reorder the data on disk by creating an intermediate table and loading the data in the desired order. For example:

CREATE TABLE new_table (LIKE old_table)
AS SELECT * FROM old_table ORDER BY myixcolumn;

DROP old_table;

ALTER TABLE new_table RENAME TO old_table;

CREATE INDEX myixcolumn_ix ON old_table;

VACUUM ANALYZE old_table;


Comments