Database / Snowflake Interview Questions
What are micro-partitions in Snowflake and how do they enable automatic data clustering?
Micro-partitions are the fundamental storage units in Snowflake. When data is loaded, Snowflake automatically divides it into contiguous blocks of 50–500 MB of uncompressed data (typically ~16 MB compressed on disk). Each micro-partition is stored as a columnar compressed file in cloud object storage. The key optimization property comes from the rich metadata Snowflake stores for each partition in the Cloud Services layer — not the data itself.
Per micro-partition, Snowflake records: minimum and maximum column values for every column, null count, distinct value count, and row count. When the query optimizer evaluates a predicate like WHERE order_date = '2024-03-15', it reads this metadata and skips any micro-partition whose max(order_date) is earlier or whose min(order_date) is later. This is partition pruning — no data bytes are read from skipped partitions.
Automatic clustering refers to the fact that data loaded chronologically (e.g., daily appended events) naturally groups similar values into the same micro-partitions. For tables where load order does not match query patterns, explicit clustering keys can trigger reorganization. The better the clustering, the fewer micro-partitions must be scanned per predicate, directly reducing query cost.
-- Check clustering quality of the sales table
SELECT SYSTEM$CLUSTERING_INFORMATION('sales', '(order_date)');
-- Micro-partition statistics via Information Schema
SELECT table_name, clustering_key, row_count, bytes
FROM information_schema.tables
WHERE table_schema = 'PUBLIC';
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
