Database / Snowflake Interview Questions
What is the metadata cache (Cloud Services layer cache) and how does it speed up queries?
The metadata cache lives entirely within the Cloud Services layer and is separate from both the result cache and the local SSD cache on Virtual Warehouse nodes. It stores structural and statistical information about every micro-partition for every table: per-column minimum and maximum values, null counts, row counts, and approximate distinct value counts. This metadata is updated in real time as data is loaded, inserted, or deleted.
The metadata cache serves two critical performance functions. First, the query optimizer reads it before any data scan begins, using column min/max ranges to decide which micro-partitions are irrelevant to the predicate (partition pruning) — this happens entirely within Cloud Services and costs no warehouse credits. Second, certain queries can be answered completely from metadata without reading a single data file, consuming zero compute credits:
SELECT COUNT(*) FROM orders— answered from stored row count.SELECT MIN(order_date), MAX(order_date) FROM orders— answered from stored min/max.SELECT COUNT(DISTINCT region) FROM orders(approximate) — can use HLL sketches.- Schema queries:
DESCRIBE TABLE,SHOW TABLES.
More Related questions...