A persisted query result is a previously computed Snowflake query result retained for reuse. Snowflake usually keeps results for about 24 hours, allowing repeated reports or transformations to return results without re-executing the query. section 9.2.1
Snowflake reuses a persisted result only when the reuse conditions hold:
- The query must be exactly identical, including uppercase and lowercase differences. section 9.2.1
- The underlying table data must not have changed. section 9.2.1
- The session parameter USE_CACHED_RESULT must remain TRUE, its default setting. section 9.2.2
When reuse occurs, the query profile shows a single step indicating that results were reused. Retrieval avoids query execution, an active virtual warehouse, and credit consumption, which can improve performance and control costs. section 9.2.1
Benchmarking without result reuse
To compare execution statistics across warehouse sizes, run ALTER SESSION SET USE_CACHED_RESULT = FALSE;. Snowflake then executes the query each time, enabling comparisons of execution time, spilling, and credits consumed. Restore TRUE afterward for normal performance. section 9.2.2
Figure 9.5 Query profile after executing the query from listing 9.1 a second time, indicating that the query results were reused
Inspect the query profile to verify that a repeated query used the persisted result rather than executing again. section 9.2.1
