CertSafari
    Snowflake SnowPro Core Certification (COF-C03)· Lessons

    Domain 4 · Lesson 15/19

    Snowflake caching: result cache, metadata and warehouse cache

    Use Snowflake caching

    19 min read
    5.25% of exam
    9 sources
    Published 20 Oct 2026
    Docs as of 4 Oct 2026

    What you will be able to do

    • Tell the query result cache, metadata-based results and the warehouse cache apart by where they live and what clears each one
    • Predict whether a repeated query will reuse a persisted result, and name the change that stops it
    • Post-process an earlier result with RESULT_SCAN
    • Measure warehouse cache use and choose an AUTO_SUSPEND value that keeps it warm for the workload
    • Benchmark a query with USE_CACHED_RESULT turned off so that result reuse does not hide its real run time

    Key concept

    Cache lifetime follows the layer — Persisted query results and table metadata are held outside the virtual warehouse, so they are still there after a warehouse suspends. The warehouse cache is table data on the warehouse's own compute, and it is lost when the warehouse suspends.

    1.Three caches and where each one lives

    Snowflake can answer a query without doing all of the work again in three ways, and each way is lost at a different moment. The query result cache returns a result that was already computed. A metadata-based result answers the query from what Snowflake already knows about the table, without reading any rows. The warehouse cache keeps table data that a running warehouse has already read, so later queries on the same warehouse can skip some reads from storage. To tell the three apart on the exam, ask what each one depends on.

    The answer comes from the architecture. Using Snowflake's three layers: storage, compute, cloud services as the frame: the cloud services layer "handles request query caching" and runs on a distributed metadata store, while the warehouse cache sits on the warehouse's compute nodes. That is why a suspended warehouse keeps returning 24-hour-old results and serving COUNT(*) from metadata, yet its next scan of a table starts with an empty local cache.

    The three caches side by side
    CacheWhat it holdsNeeds a running warehouse?What clears it or switches it off
    Query result cacheThe finished result of an earlier queryNoExpiry after 24 hours (extended each time the result is reused, up to 31 days), changed data, or USE_CACHED_RESULT = FALSE
    MetadataPer-micro-partition facts such as the range of values in each columnNoKept up to date by Snowflake as the table changes
    Warehouse cacheTable data the warehouse has already scannedYesDropped when the warehouse suspends; size grows with warehouse size

    Checkpoint 1 of 10· Match them up

    Match each Snowflake cache to what it holds and what happens to it

    Tap a term, then the definition that fits it.

    Sources12

    2.When a persisted result is reused

    When a query repeats and its data has not changed, Snowflake returns the stored result and skips execution entirely. In the docs' words, "Snowflake bypasses query execution and, instead, retrieves the result directly from the cache." This only happens under a strict set of conditions, and the first one surprises most people: the query text must match exactly.

    Four logically equivalent queries. Only the second one is an exact match for the first.sql
    SELECT DISTINCT(severity) FROM weather_events; SELECT DISTINCT(severity) FROM weather_events; SELECT DISTINCT(severity) FROM weather_events we; select distinct(severity) from weather_events;

    Snowflake does not clean up the text before matching. It does not remove aliases, fold case or work out that two queries mean the same thing. Changing an alias from O to o is enough to miss the cache. The other conditions concern what the query calls and who runs it.

    • No non-reusable functions. A function that returns different results for successive runs of the same query rules out reuse. Snowflake gives UUID_STRING, RANDOM and RANDSTR as examples, and the same logic covers any function whose value changes from one run to the next. The function is not evaluated once and stored with the result.
    • No external functions.
    • No hybrid tables. A query that selects from a hybrid table does not benefit from the result cache, even when it also joins a standard table.
    • The right privileges. For a SELECT, the role running it needs access to every table in the cached query. For a SHOW, the role must be the same role that produced the cached result.

    Checkpoint 2 of 10· Check yourself

    Each query below is run a second time with exactly the same text, and none of the tables has changed. Which rerun cannot be answered from the query result cache?

    Checkpoint 3 of 10· Exam question

    A developer rewrites a report query, changing only a table alias from uppercase O to lowercase o; the join logic and filters are otherwise identical to a query that ran minutes earlier against unchanged data. Will the rewritten query reuse the earlier persisted result?

    Checkpoint 4 of 10· Exam question

    A dashboard query embeds CURRENT_TIMESTAMP() to stamp each report and is executed twice, a few minutes apart, against unchanged source data. How does the query result cache behave across these two executions?

    Sources34

    3.How long a result lives and what invalidates it

    A persisted result lasts 24 hours, and each reuse restarts that 24 hours. Snowflake resets the retention period every time the result is reused, up to 31 days after the query first ran. After that the result is purged, and the next run computes and stores a new one. A dashboard query that runs every hour can therefore be served from cache for a month, but no longer.

    Results larger than 100 KB come with a separate 6-hour limit, and it applies to the security token used to fetch them, not to the result. While the result is still in cache, a client can request a new token. Smaller results do not use a token. The Spark connector's token lasts 24 hours regardless of result size.

    No. A result is invalidated by changes to the data behind it, and also by changes to how that data is stored. A stored result stops being reusable in these cases:

    • the table data contributing to the result has changed
    • the table's micro-partitions have been reclustered or consolidated because of changes elsewhere in the table
    • a configuration option that affected how the result was produced has changed

    External tables follow the same 24-hour rule and add two more invalidating events. Any DDL that changes the external table definition invalidates results, and so does any refresh, automatic or manual, that changes which files are registered in the table's metadata. The reverse also holds, and it causes problems: if AUTO_REFRESH = FALSE or the refresh is misconfigured, new files in cloud storage do not invalidate anything, and queries keep returning outdated cached results.

    Checkpoint 5 of 10· Check yourself

    A BI dashboard runs the same query text every hour against a table that nobody writes to. The result is 2 MB. Which statement about how long Snowflake can keep reusing that result is correct?

    Sources35

    4.Turning result reuse off with USE_CACHED_RESULT

    Result reuse is on by default and controlled by one parameter, USE_CACHED_RESULT. It can be overridden at the account, user and session level (see Parameter types and precedence (account, object, session)). Setting it to FALSE for a session makes every query in that session compute its answer from current data. This is what you need while checking a fix during an incident, or while timing a query.

    Turning off result reuse for the current session before benchmarkingsql
    alter session set use_cached_result = false;

    Each setting affects only its own cache. USE_CACHED_RESULT controls only result reuse, so the warehouse cache stays warm and repeated scans still benefit from it. AUTO_SUSPEND controls only how long the warehouse cache survives and has no effect on result reuse. Settings such as clustering keys or statement timeouts do not turn either cache on or off.

    Checkpoint 6 of 10· Fill the gap

    You are timing a query and need every run in your session to compute its answer from current data instead of returning a stored result. Which parameter completes this statement?

    alter session set  ?  = false;

    Checkpoint 7 of 10· Exam question

    During an incident investigation, an engineer needs every query in the current session to recompute against live data instead of returning persisted results, so recent fixes can be verified. Which setting achieves this?

    Sources36

    5.Post-processing a result with RESULT_SCAN

    A persisted result can also be queried. The RESULT_SCAN table function returns an earlier query's result as a table, so you can filter, join or aggregate it. This helps in two situations. One is building a complex query in steps, where each new layer reads the previous result instead of recomputing it. The other is output that SQL cannot otherwise use: you cannot call a stored procedure inside a larger SQL statement, and SHOW, DESCRIBE and CALL return results that are hard to reuse, so post-processing their stored result is the way to work with them.

    Run SHOW TABLES, then list the empty tables by filtering its stored resultsql
    SELECT "schema_name", "name" as "table_name", "rows" FROM table(RESULT_SCAN(LAST_QUERY_ID())) WHERE "rows" = 0;

    LAST_QUERY_ID() points RESULT_SCAN at the statement you just ran. The SHOW output columns are lowercase, so they must be written in double quotes. The pipe operator ->> does the same job without first displaying the output of the SHOW or SELECT.

    Checkpoint 8 of 10· Fill the gap

    SHOW TABLES has just run. The statement below lists only the empty tables by querying the stored output of that SHOW command as if it were a table. Which table function completes it?

    SELECT "schema_name", "name" as "table_name", "rows" FROM table( ? (LAST_QUERY_ID())) WHERE "rows" = 0;

    Sources3

    6.Queries answered from metadata alone

    Some queries never reach a warehouse because Snowflake already knows the answer. For each micro-partition it stores metadata that includes the range of values in each column and the number of distinct values (see Micro-partitions, pruning and clustering depth). A query such as SELECT COUNT(*) FROM …, or SELECT CURRENT_DATABASE(), is computed purely from metadata, without reading table data, and no virtual warehouse processes it.

    Query Profile shows which shortcut served a fast query. A Metadata-based Result node means the answer came from metadata. A Query Result Reuse node means an earlier result was returned. Neither uses warehouse time, which explains a query that finished in milliseconds with no warehouse credits. Client commands work the same way: SHOW TABLES does not need a warehouse to retrieve its data, so no warehouse charges apply.

    Checkpoint 9 of 10· Check yourself

    Your team's only warehouse is suspended, and nobody may resume it or spend warehouse credits. Which of these statements can still return its answer?

    Sources782

    7.The warehouse cache: measuring it and keeping it warm

    A running warehouse keeps the table data it reads, and later queries on the same warehouse can read that data from the cache instead of from the table. Larger warehouses have more compute resources and therefore a larger cache. Unlike a reused result, a query that uses this cache still runs on the warehouse: it scans less remote data, but it still uses compute.

    You can measure the cache for one query or for a whole warehouse. For one query, open the query profile, select the table scan operator, and read Percentage scanned from cache under Statistics. For a warehouse, weight that percentage by bytes scanned across a month of QUERY_HISTORY. A low figure on a warehouse that runs frequent, similar queries suggests that tuning the cache could improve performance. This query needs the shared SNOWFLAKE database, which by default only ACCOUNTADMIN can query.

    Share of scanned bytes served from the warehouse cache over the last month, per warehousesql
    SELECT warehouse_name
      ,COUNT(*) AS query_count
      ,SUM(bytes_scanned) AS bytes_scanned
      ,SUM(bytes_scanned*percentage_scanned_from_cache) AS bytes_scanned_from_cache
      ,SUM(bytes_scanned*percentage_scanned_from_cache) / SUM(bytes_scanned) AS percent_scanned_from_cache
    FROM snowflake.account_usage.query_history
    WHERE start_time >= dateadd(month,-1,current_timestamp())
      AND bytes_scanned > 0
    GROUP BY 1
    ORDER BY 5;

    The main control is AUTO_SUSPEND and AUTO_RESUME. Every suspension empties the cache, and an idle warehouse that is still running keeps using credits. The right value depends on the gap between related queries.

    Snowflake's suggested auto-suspend settings by workload
    WorkloadSuggested auto-suspendReason
    TasksImmediateNothing on the warehouse reuses the cache between task runs
    DevOps, DataOps, Data ScienceAbout 5 minutesAd hoc, one-off queries gain little from the cache
    BI and SELECT query warehousesAt least 10 minutesKeeps the cache warm for users running similar queries

    These are starting points, not fixed rules. If a warehouse runs one query every 30 minutes, a 10-minute suspend gets the worst of both: it pays for 10 idle minutes each cycle and still finds the cache empty when the next query arrives. In Snowsight, the Suspend After field is in minutes. In SQL, AUTO_SUSPEND is in seconds, so 10 minutes is written as 600.

    Setting a 10-minute auto-suspend in SQL (the value is in seconds)sql
    ALTER WAREHOUSE my_wh SET AUTO_SUSPEND = 600;

    Checkpoint 10 of 10· Fill the gap

    A BI warehouse serves analysts who run similar queries, so it should stay up for 10 minutes after its last query to keep its cache warm. Which value completes the statement?

    ALTER WAREHOUSE my_wh SET AUTO_SUSPEND =  ? ;

    Sources249

    Practise it for real

    Separate the result cache from the warehouse cache in a benchmark on the TPC-H sample data

    1. 1.Run use database snowflake_sample_data; and use schema tpch_sf1;, then alter session set query_tag = 'tpch_test';

      Why: The query tag lets you find exactly these runs later in Query History and QUERY_HISTORY.

      You should see: The session context is set and the statements succeed.

    2. 2.Run alter session set use_cached_result = false;

      Why: Without this, the second run of any query would return the stored result and you would be timing a cache lookup instead of the query.

      You should see: Every later query in this session is computed again from the data.

    3. 3.Run the same TPC-H query (for example, the lineitem pricing summary) three times in a row on one running warehouse.

      Why: The first run reads from storage. Later runs can read from the warehouse cache, which stays active because only result reuse was turned off.

      You should see: The later runs are usually faster than the first, and their table scan shows a non-zero Percentage scanned from cache.

    4. 4.Query snowflake.account_usage.query_history filtered on query_tag = 'tpch_test', reading total_elapsed_time and execution_time.

      Why: This records the timings outside Snowsight so you can compare runs.

      You should see: One row per run. Account usage views can lag, so recent runs may take a little time to appear.

    Stuck? Get a nudge

    If every run takes almost no time, check whether the use_cached_result setting was applied in the same session as the queries.

    Sources

    (9)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “performs query compilation and optimization, handles request query caching, and more.”
      ↩︎ Three caches and where each one lives
      “using a highly available, distributed metadata store for global state management”
      ↩︎ Three caches and where each one lives
    2. 2.
      “This cache is dropped when the warehouse is suspended, which might result in slower initial performance for some queries after the warehouse is resumed.”
      ↩︎ Three caches and where each one lives
      “SHOW TABLES does not require a warehouse to retrieve data, so no charges apply.”
      ↩︎ Queries answered from metadata alone
      “the larger the warehouse and, therefore, more compute resources in the warehouse, the larger the cache”
      ↩︎ The warehouse cache: measuring it and keeping it warm
      “This cache is dropped when the warehouse is suspended, which might result in slower initial performance for some queries after the warehouse is resumed.”
      ↩︎ Key concept
      “Each warehouse, when running, maintains a cache of table data accessed as queries are processed by the warehouse.”
      ↩︎ Checkpoint
    3. 3.
      “Snowflake bypasses query execution and, instead, retrieves the result directly from the cache.”
      ↩︎ When a persisted result is reused
      “which return different results for successive runs of the same query”
      ↩︎ When a persisted result is reused
      “UUID_STRING, RANDOM, and RANDSTR are good examples of non-reusable functions.”
      ↩︎ When a persisted result is reused
      “If the query was a SHOW query, the role executing the query must match the role that generated the cached results.”
      ↩︎ When a persisted result is reused
      “Meeting all these conditions does not guarantee that Snowflake reuses the query results.”
      ↩︎ When a persisted result is reused
      “Snowflake resets the 24-hour retention period for the result, up to a maximum of 31 days”
      ↩︎ How long a result lives and what invalidates it
      “the security token used to access large persisted query results (i.e. greater than 100 KB in size) expires after 6 hours.”
      ↩︎ How long a result lives and what invalidates it
      “Any configuration options that affect how the result was produced have not changed.”
      ↩︎ How long a result lives and what invalidates it
      “result reuse is enabled, but can be overridden at the account, user, and session level using the USE_CACHED_RESULT session parameter.”
      ↩︎ Turning result reuse off with USE_CACHED_RESULT
      “You can perform post-processing by using the RESULT_SCAN table function.”
      ↩︎ Post-processing a result with RESULT_SCAN
      “You can also use the pipe operator (->>) instead of the RESULT_SCAN function to process the results of a previous command.”
      ↩︎ Post-processing a result with RESULT_SCAN
      “Any difference in syntax, including lowercase versus uppercase, or the use of table aliases, will inhibit 100% cache reuse.”
      ↩︎ Exam trap 1
      “The table’s micro-partitions have not changed (e.g. been reclustered or consolidated) due to changes to other data in the table.”
      ↩︎ Exam trap 2
      “result reuse is enabled, but can be overridden at the account, user, and session level using the USE_CACHED_RESULT session parameter.”
      ↩︎ Exam trap 3
      “For persisted query results of all sizes, the cache expires after 24 hours.”
      ↩︎ Exam trap 5
      “Any difference in syntax, including lowercase versus uppercase, or the use of table aliases, will inhibit 100% cache reuse.”
      ↩︎ Prediction
      “The query does not include non-reusable functions, which return different results for successive runs of the same query.”
      ↩︎ Checkpoint
    4. 4.
      “Queries that select from hybrid tables do not benefit from the query results cache.”
      ↩︎ When a persisted result is reused
      “check the Percentage scanned from cache under Statistics.”
      ↩︎ The warehouse cache: measuring it and keeping it warm
    5. 5.
      “Changes in the set of files in cloud storage that are registered in the external table metadata.”
      ↩︎ How long a result lives and what invalidates it
      “which lead to outdated query results”
      ↩︎ How long a result lives and what invalidates it
    6. 7.
      “A query whose result is computed based purely on metadata, without accessing any data. These queries are not processed by a virtual warehouse.”
      ↩︎ Queries answered from metadata alone
      “A query that reuses the result of a previous query.”
      ↩︎ Queries answered from metadata alone
    7. 8.
      “The range of values for each of the columns in the micro-partition.”
      ↩︎ Queries answered from metadata alone
    8. 9.
      “Snowflake recommends setting auto-suspend to at least 10 minutes to maintain the cache for users.”
      ↩︎ The warehouse cache: measuring it and keeping it warm
      “if a warehouse executes a query every 30 minutes, it does not make sense to set the auto-suspend setting to 10 minutes.”
      ↩︎ The warehouse cache: measuring it and keeping it warm
      “change the auto-suspend time limit, which is specified in seconds, not minutes.”
      ↩︎ Exam trap 4

    Ready to test yourself?

    Practise the 21 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.