1. A Snowflake architect is designing the clustering strategy for a TRANSACTIONS fact table containing 4 billion rows. The table is primarily queried by analysts who filter on TRANSACTION_DATE (a DATE column with ~1,000 distinct values) and occasionally filter on MERCHANT_CATEGORY (a VARCHAR column with 25 distinct values). The architect wants to maximize micro-partition pruning for the most common query pattern. Which clustering key definition should the architect choose?
- A. CLUSTER BY (TRANSACTION_DATE)✓ Correct
- B. CLUSTER BY (MERCHANT_CATEGORY, TRANSACTION_DATE)
- C. CLUSTER BY (TRANSACTION_DATE, MERCHANT_CATEGORY)
- D. CLUSTER BY (TRANSACTION_ID) — the primary key always provides the best pruning
Explanation
Option A is correct. For maximum micro-partition pruning, the leading column of the clustering key should be the highest-cardinality column that appears most frequently in WHERE clause filters — TRANSACTION_DATE with ~1,000 distinct values fits perfectly as the sole key for the dominant query pattern. Option B is wrong: placing MERCHANT_CATEGORY (only 25 distinct values, low cardinality) first means Snowflake sorts data by that column first, resulting in poor pruning for date-range queries. Option C adds MERCHANT_CATEGORY as a secondary key, which is not harmful but adds unnecessary reclustering cost because the column has very low cardinality and queries rarely filter on it exclusively. Option D is incorrect: clustering on a high-cardinality synthetic primary key like TRANSACTION_ID creates extremely fine-grained micro-partitions with almost no rows per unique value, providing no pruning benefit for range or categorical filters and wasting significant credits.