The keyword that specifies that the column is the sort key for the table. In Snowflake, SORTKEY
from Redshift can be migrated to CLUSTER BY
because both optimize data storage for query performance. CLUSTER BY
in Snowflake organizes data on specified columns, similar to how SORTKEY
orders data in Redshift.
Copy [ COMPOUND | INTERLEAVED ] SORTKEY( column_name [, ...] )
Copy CREATE TABLE table1 (
col1,
col2,
col3,
col4
)
COMPOUND SORTKEY (col1, col3)
AS SELECT * FROM table_test;
CREATE TABLE table2 (
col1
)
INTERLEAVED SORTKEY (col1)
AS SELECT * FROM table_test;
CREATE TABLE table3 (
col1
)
SORTKEY (col1)
AS SELECT * FROM table_test;
Copy CREATE TABLE table1
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "redshift", "convertedOn": "09/17/2024" }}'
(
col1,
col2,
col3,
col4
)
--** SSC-FDM-RS0002 - THE PERFORMANCE OF THE CLUSTER BY MAY VARY COMPARED TO THE PERFORMANCE OF SORTKEY **
CLUSTER BY (col1, col3)
AS SELECT * FROM
table_test;
CREATE TABLE table2
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "redshift", "convertedOn": "09/17/2024" }}'
(
col1
)
--** SSC-FDM-RS0002 - THE PERFORMANCE OF THE CLUSTER BY MAY VARY COMPARED TO THE PERFORMANCE OF SORTKEY **
CLUSTER BY (col1)
AS SELECT * FROM
table_test;
CREATE TABLE table3
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "redshift", "convertedOn": "09/17/2024" }}'
(
col1
)
--** SSC-FDM-RS0002 - THE PERFORMANCE OF THE CLUSTER BY MAY VARY COMPARED TO THE PERFORMANCE OF SORTKEY **
CLUSTER BY (col1)
AS SELECT * FROM
table_test;