All Collections
Database Objects
Clustering keys (Snowflake)
Clustering keys (Snowflake)

How to create and use clustering keys with Snowflake

SqlDBM Support avatar
Written by SqlDBM Support
Updated over a week ago

A clustering key is a subset of columns in a table (or expressions on a table) that are explicitly designated to co-locate the data in the table in the same micro-partitions. This is useful for very large tables where the ordering was not ideal (when the data was inserted/loaded), or extensive DML has caused the table’s natural clustering to degrade.

Create a Clustering Key

You can only create one clustering Key per table.

  1. Click on a table to access the properties on the right panel

  2. Open Clusters & Keys tab

  3. Click the "CK" button on the bottom bar to create a clustering key

  4. Expand the Members menu and specify the clustering key using columns (a) or expressions (b).

    1. Select the "Columns" radio button and tick the columns, which will form part of the clustering key in order of first to last.

    2. To use a custom expression, select the "Expression" radio button and manually specify the comma-separated clustering key.

Properties:

You may:

• Set clustering key name

• Select member columns in a specific order

• Edit the clustering expression manually

• Add or edit the CK description/comment

Did this answer your question?