The Role of Caching in Snowflake Performance
Instruction: Explain the role of caching in Snowflake and how it enhances query performance.
Updated
Official answer
Snowflake has several reuse mechanisms with different purposes. Persisted query results can avoid recomputing an eligible query; a running warehouse can cache table data; metadata supports planning and pruning.
Persisted-result reuse depends on documented conditions such as matching query text, unchanged relevant data/partitions, compatible settings and appropriate access. Nondeterministic functions can prevent reuse. Meeting the listed conditions still does not guarantee reuse. Results normally expire after 24 hours; reuse resets that period, up to 31 days from the original execution.
Warehouse data cache helps queries that scan previously accessed data on that warehouse. It is separate from the persisted result and is dropped on suspension. Keeping a warehouse running to retain cache consumes credits, so compare likely reuse with idle cost.
Metadata such as partition value ranges can reduce work without serving a complete cached result. It is inaccurate to treat every fast query as a result-cache hit.
When benchmarking, record cache state. Disabling USE_CACHED_RESULT prevents persisted-result reuse but does not clear the warehouse's data cache. Compare cold/warm behavior, queue time, bytes scanned and result correctness; do not claim a faster warehouse from a comparison where one run merely reused an old result.
Persisted query results, warehouse cache, partition metadata