Home  >  Blog  >   Snowflake  > 

How to create an Index in Snowflake

Snowflake does not support Index, but it uses a clustering key to get the query performance. The clustering key is defined as the subset of externally appointed columns for co-locating the data in the table. This blog allows you to create the Clustering key.

Rating: 4
  
 
188
  1. Share:
Snowflake Articles

Create an Index in Snowflake

Rather than creating or dropping the index in Snowflake, we can utilize the clustering key for achieving the query performance. For creating the clustering key, we use ALTER TABLE . CLUSTER BY command:

Syntax:

alter table table_name cluster by (column1, column2, …, columnN);

Example:

Cluster on a single column

alter table active_users1
cluster by (id1)
Looking forward to a career in a cloud data warehousing domain? Check out the "Snowflake Training" and get certified today

Cluster on multiple columns

alter table active_users1
cluster by (id1, active1)

But, we should be careful about using the clustering keys. The clustering key must be used only when we are handling tables of the below properties:

  • Tables containing a vast amount of data.
  • Data from the tables are filtered frequently.
MindMajix Logo

Subscribe to explore the latest tech updates, career transformation tips, and much more.

Conclusion

Clustering enables us to co-locate the data in similar micro-partitions. It is suitable for huge tables where the ordering is not good. I hope this article gives you adequate information about creating Clustering keys.

Snowflake Related Articles


▶  Snowflake vs Redshift
▶  Snowflake vs BigQuery
▶  Snowflake vs Databricks
▶  Snowflake vs Azure
▶  Snowflake vs Hadoop
▶  Snowflake Time Travel

Join our newsletter
inbox

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
NameDates
Snowflake TrainingJun 28 to Jul 13
Snowflake TrainingJul 02 to Jul 17
Snowflake TrainingJul 05 to Jul 20
Snowflake TrainingJul 09 to Jul 24
Last updated: 27 June 2022
About Author
Viswanath V S

Viswanath is a passionate content writer of Mindmajix. He has expertise in Trending Domains like Data Science, Artificial Intelligence, Machine Learning, Blockchain, etc. His articles help the learners to get insights about the Domain. You can reach him on Linkedin