← Back to Tutorials

18. Caching

Result Cache

Query results are cached for 24 hours (or until underlying data changes). Identical queries served from cache — no warehouse needed.

-- First run: executes (billed)
SELECT COUNT(*) FROM sales;

-- Second run: served from result cache (free, instant)
SELECT COUNT(*) FROM sales;

Warehouse Cache

Data files cached in SSD on warehouse nodes. Persists while warehouse is running. If warehouse is suspended, cache is lost.

Metadata Cache

Object metadata (row count, column stats, partitions) is always cached and served instantly for optimization.

Best Practices

SELECT * FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));
✏️ Exercise: Run the same query twice. Compare execution times using QUERY_HISTORY. Note which run used cached results.