This is an English translation of a Japanese blog. Some content may not be fully translated.
Snowflake

Snowflake Cache

# Cache Name Cache Target Available Users Storage Layer Duration
1 Result Cache Query results All users with the same role that executed the query Snowflake 24 hours
2 Metadata Cache Information about tables All users Snowflake Always
3 Data Cache File headers and column data of query results Users who ran the same virtual warehouse Warehouse (SSD) While warehouse is running

No compilation cache exists; compilation is always required.

How to Disable Cache Usage

Notes

Result Cache

https://docs.snowflake.com/en/user-guide/querying-persisted-results.html#retrieval-optimization

Typically, query results are reused when all of the following conditions are met:

  • The new query syntactically matches a previously executed query.
  • The query does not contain functions that must be evaluated at runtime (e.g., CURRENT_TIMESTAMP() and UUID_STRING() ). The CURRENT_DATE() function is an exception to this rule. CURRENT_DATE() is evaluated at runtime, but queries using CURRENT_DATE() can still use the query reuse feature.
  • The query does not contain user-defined functions (UDFs) or external functions .
  • The table data contributing to the query results has not changed.
  • The previously persisted results of the query are still available.
  • The role accessing the cached results has the necessary privileges.
    • If the query is a SELECT query, the role executing the query must have the required access privileges on all tables used in the cached query.
    • If the query is a SHOW query, the role executing the query must match the role that generated the cached results.
  • Configuration options that affect how results are generated have not changed.
  • The micro-partitions of the table have not changed due to other data changes within the table (e.g., reclustering or consolidation).

Even if all these conditions are met, Snowflake does not guarantee that query results will be reused.

References

Suggest an edit on GitHub