Snowflake lets you speed up or bypass query execution by leveraging or disabling its result, warehouse, and metadata caches.
Snowflake maintains a result cache (final result sets), warehouse cache (micro-partitions in local SSD), and metadata cache (file headers and statistics). Each layer accelerates repeat queries without extra cost.
Set the USE_CACHED_RESULT
session parameter. TRUE
(default) lets identical SELECT statements retrieve data from the result cache instantly.FALSE
forces full re-execution, useful during data validation.
Query the QUERY_HISTORY
view or the UI. The BYTES_SCANNED
field will be 0
when the result cache is used, and CACHE_HIT
appears in the UI.
When a virtual warehouse is warm, Snowflake keeps recently accessed micro-partitions in SSD. Subsequent queries touching the same data avoid remote storage, lowering latency.Suspend or resize actions clear this cache.
Run a fast SELECT COUNT(*)
or SELECT 1
from large tables right after the warehouse resumes. This brings data into SSD before user traffic starts.
Snowflake stores file listings and statistics for external S3/GCS stages for about 60 minutes.Use ALTER STAGE … REFRESH
or the VALIDATE
function to refresh the cache when new files arrive.
USE_CACHED_RESULT
on in production dashboards.CLUSTER BY
to align frequently filtered columns with micro-partitions.Disable cached results, run the query, then turn caching back on so later reports are fast.
ALTER SESSION SET USE_CACHED_RESULT = FALSE;
SELECT customer_id, SUM(total_amount)
FROM Orders
WHERE order_date > CURRENT_DATE - INTERVAL '7 days'
GROUP BY customer_id;
ALTER SESSION SET USE_CACHED_RESULT = TRUE;
Leaving USE_CACHED_RESULT = FALSE
in a long-lived session makes every query expensive.Always reset to TRUE
after testing.
Suspending a warehouse empties its SSD cache. Schedule warm-up queries or avoid frequent stop-start cycles for critical workloads.
.
Yes. Any DML that mutates the underlying tables automatically invalidates cached results for affected micro-partitions.
Scaling up preserves the cache; scaling down or suspending clears it because new clusters start with empty SSDs.
Roughly 60 minutes for external stages. Snowflake refreshes automatically, but you can force a refresh with ALTER STAGE … REFRESH.