HomeInterview QuestionsWhat is the difference between a distribution key …

What is the difference between a distribution key and a sort key?

🟡 Medium Conceptual Junior level
1Times asked
Sep 2026Last seen
Sep 2026First seen

💡 Model Answer

In Snowflake, a distribution key and a sort key serve different purposes. The distribution key determines how rows are physically distributed across the micro‑partitions and compute nodes. By hashing or round‑robin on the distribution key, Snowflake ensures that related rows are colocated, which is critical for join performance and reduces data shuffling. A sort key, on the other hand, orders the data within each micro‑partition. This ordering enables range pruning during query execution, allowing Snowflake to skip entire partitions that fall outside the filter predicates. While the distribution key is about data placement for parallelism, the sort key is about data ordering for efficient scanning. You typically choose a distribution key on columns that appear in join predicates, and a sort key on columns used in range filters or ORDER BY clauses. Snowflake also allows composite keys for both distribution and sorting, and you can change them by recreating the table or using ALTER TABLE … CLUSTER BY. Understanding the trade‑offs—distribution for join speed versus sorting for scan speed—is key to designing performant Snowflake schemas.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500