CertSafari
    Snowflake SnowPro Advanced: Administrator (ADA-C02)· Lessons

    Domain 4 · Lesson 16/24

    Snowflake caching, search optimization and query acceleration

    Monitor and analyze Snowflake performance.

    13 min read
    4% of exam
    8 sources
    Published 20 Oct 2026
    Docs as of 4 Oct 2026

    What you will be able to do

    • Explain when the result cache is reused, how long a result lasts, what stops reuse, and how USE_CACHED_RESULT controls it
    • Size AUTO_SUSPEND so the warehouse cache survives between related queries
    • Recognise queries answered from metadata without a warehouse
    • Choose between search optimization, a materialized view and clustering for a slow query
    • Make external tables fast with partition columns and materialized views
    • Find queries eligible for the query acceleration service and set its scale factor

    1.The result cache: persisted query results

    The fastest query is one Snowflake doesn't run. When a query finishes, its result is persisted for 24 hours. If the same query comes in again and nothing it depends on has changed, Snowflake returns the stored result and skips execution. Each reuse resets the 24-hour period, up to 31 days from the first run. After that, the result is purged and the next run computes a new one.

    Reuse is strict. All of the following must hold:

    • The query text matches exactly. A different letter case or an added table alias is enough to prevent reuse.
    • The query uses no non-reusable functions such as UUID_STRING, RANDOM or RANDSTR, and no external functions.
    • The query does not select from hybrid tables.
    • The data in the tables behind the result has not changed, and the table's micro-partitions have not been reclustered or consolidated.
    • Configuration options that affect the result are unchanged.
    • The role has the privileges on every table in the cached query. For SHOW, it must be the same role that produced the result.

    Even when every condition is met, Snowflake doesn't guarantee reuse. The USE_CACHED_RESULT parameter, which is on by default, can switch reuse off at the account, user or session level. Benchmarking is the usual reason to turn it off, so that repeated runs measure real execution. A reused result also lets you build on earlier output: RESULT_SCAN, or the ->> pipe operator, lets you query the result of a SHOW, DESCRIBE or CALL like a table.

    Checkpoint 1 of 5· Check yourself

    At 09:00 an analyst runs SELECT DISTINCT(severity) FROM weather_events;. The table's data does not change after that. Which of these reruns at 10:00 is blocked from reusing the persisted result?

    Sources1

    2.Warehouse cache, metadata answers and AUTO_SUSPEND

    A running warehouse keeps a local cache of the table data its queries have read. A later query on the same warehouse that needs the same data reads it from the cache instead of remote storage. The cache only lives as long as the warehouse runs. Suspending drops it, so the first query after a resume reads everything from remote storage again. Each TableScan reports the share it read from cache as percentage scanned from cache. The column percentage_scanned_from_cache in ACCOUNT_USAGE.QUERY_HISTORY lets you compute that share per warehouse. A low share on a warehouse with frequent, similar queries means the cache is being lost.

    AUTO_SUSPEND is a trade-off between keeping the cache and paying for idle time, because a running warehouse uses credits even when no query is running. The guidance:

    • Tasks: suspend immediately.
    • DevOps, DataOps and data science: about 5 minutes, because ad-hoc queries gain little from the cache.
    • BI and SELECT warehouses: at least 10 minutes, so dashboard users keep a warm cache.

    Match the setting to how often queries actually arrive. If queries come every 30 minutes, a 10-minute suspend pays for idle time and still loses the cache before the next query. AUTO_SUSPEND is set in seconds, not minutes.

    Keep the warehouse, and its cache, alive for 10 minutes of idle timesql
    ALTER WAREHOUSE my_wh SET AUTO_SUSPEND = 600;

    Some queries need neither cache because they never touch table data. A query such as SELECT COUNT(*) FROM a table, or SELECT CURRENT_DATABASE(), can be answered from metadata alone. Its profile shows a single Metadata-based Result operator, and no virtual warehouse processes it. Suspending a warehouse has no effect on these queries.

    The three caches compared
    CacheWhat it holdsNeeds a running warehouse?What makes it unusable
    Result cache (persisted query results)Final result of a queryNo24 hours without reuse (31-day maximum), changed data, different query text, USE_CACHED_RESULT = FALSE
    Warehouse (local disk) cacheTable data read by recent queriesYesWarehouse suspends
    MetadataPer-micro-partition values such as ranges and distinct countsNoNot lost on suspend; answers queries such as COUNT(*) as a Metadata-based Result

    Checkpoint 2 of 5· Fill the gap

    A BI warehouse's dashboard users should keep a warm cache through 10 minutes of idle time. Which value completes this statement?

    ALTER WAREHOUSE my_wh SET AUTO_SUSPEND =  ? ;

    Checkpoint 3 of 5· Exam question

    A BI team runs the same set of dashboards against one warehouse from 08:00 to 18:00. The warehouse has AUTO_SUSPEND = 30 and users complain the first query after each pause is slow, although result cache is not applicable. What is the best explanation and remedy?

    Sources23

    3.Search optimization, materialized views or clustering

    When a query needs lasting help rather than a warm cache, there are three table-level options. Each targets a different access pattern.

    Which optimization fits which query
    OptimizationHelps withStorage costCompute cost
    Search optimization serviceEquality searches, substring and regular expression searches, text and IP address searches, elements in VARIANT and structured types, GEOGRAPHY functionsYesYes
    Materialized viewEquality searches, range searches, sort operations; only for the rows and columns it containsYesYes
    Clustering the tableEquality and range searches; one clustering key per tableYesYes
    Query acceleration serviceQueries with filters or aggregation over large scansNoYes

    Search optimization suits selective point lookups, meaning queries expected to return a few rows, such as id = 3 or id IN (2, 3). It is a table property. Once enabled it is used automatically, and a query needs only SELECT on the table. To enable it you need OWNERSHIP of the table and the ADD SEARCH OPTIMIZATION privilege on its schema. Enable it on the specific columns you search rather than the whole table, so you don't pay to build access paths for columns nobody filters on. Adding it to a multi-terabyte table can cause a short burst of credit use while those paths are built.

    Enable search optimization for equality and IN lookups on one columnsql
    ALTER TABLE mytable ADD SEARCH OPTIMIZATION ON EQUALITY(mycol);

    A materialized view is the better choice when the same subset of a table is read again and again with range filters or sorts. It can also store flattened JSON or VARIANT data so the flattening happens once. Because a table can have only one clustering key, a materialized view is also a way to give the same data a second clustering key. It only helps queries that stay within its rows and columns. The object itself is taught in Views, secure views and materialized views.

    External tables get the same performance treatment. Queries on a large external table run fastest through a materialized view built over it. Partition columns, declared with CREATE EXTERNAL TABLE ... PARTITION BY as expressions on the file path, let a query read only the slices of files it needs rather than the whole data set. Plan the folder layout (date, time, country) before you create the table. The table's definition is covered in External tables.

    Checkpoint 4 of 5· Match them up

    A team has four slow workloads on the same large table. Match each optimization to the workload it fits best.

    Tap a term, then the definition that fits it.

    Sources4567

    4.The query acceleration service and its scale factor

    The query acceleration service (QAS) is for outlier queries that use far more resources than a warehouse's typical query. It offloads parts of their scanning and filtering to shared compute that runs in parallel. Eligible queries come in two shapes: large scans with an aggregation or a selective filter, and large scans that insert or copy many rows. A query is not eligible if it scans too few partitions, if its filter isn't selective enough or its GROUP BY cardinality is too high, if its LIMIT prevents acceleration, or if it uses nondeterministic functions such as SEQ or RANDOM. QAS works alongside search optimization. Search optimization prunes partitions first, and QAS then speeds up the remaining work.

    Turn QAS on with ENABLE_QUERY_ACCELERATION = TRUE on CREATE WAREHOUSE or ALTER WAREHOUSE. Gen2 standard warehouses and multi-cluster warehouses have it on by default. QUERY_ACCELERATION_MAX_SCALE_FACTOR caps how much compute the warehouse can lease, as a multiple of its own size. A MEDIUM warehouse costs 4 credits per hour, so a scale factor of 5 allows up to 20 extra credits per hour. The default is 8 when you enable QAS explicitly, and 2 when Snowflake enables it automatically on a Gen2 warehouse. 0 removes the cap. QAS is billed by the second, only while in use, and separately from warehouse credits.

    To find candidates, query SNOWFLAKE.ACCOUNT_USAGE.QUERY_ACCELERATION_ELIGIBLE. It lists eligible_query_acceleration_time and upper_limit_scale_factor per query, which you can aggregate by warehouse. To check one past query, call SYSTEM$ESTIMATE_QUERY_ACCELERATION with its query ID. For an eligible query it returns estimated run times at different scale factors. For an ineligible one it returns an ineligibleReason such as NO_LARGE_ENOUGH_SCAN.

    SYSTEM$ESTIMATE_QUERY_ACCELERATION output for an eligible 300-second queryjson
    {
      "estimatedQueryTimes": {
        "1": 171,
        "10": 115,
        "2": 152,
        "4": 133,
        "8": 120
      },
      "ineligibleReason": null,
      "originalQueryTime": 300.291,
      "queryUUID": "8cd54bf0-1651-5b1c-ac9c-6a9582ebd20f",
      "status": "eligible",
      "upperLimitScaleFactor": 10
    }

    Checkpoint 5 of 5· Check yourself

    To stop query acceleration spending on a MEDIUM warehouse that has ENABLE_QUERY_ACCELERATION = TRUE, an admin runs ALTER WAREHOUSE ... SET QUERY_ACCELERATION_MAX_SCALE_FACTOR = 0. What is the result?

    Sources86

    Practise it for real

    Find a query that query acceleration could speed up, estimate the gain, and enable QAS with a bounded scale factor.

    1. 1.Run: SELECT query_id, eligible_query_acceleration_time FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_ACCELERATION_ELIGIBLE WHERE start_time > DATEADD('day', -7, CURRENT_TIMESTAMP()) ORDER BY eligible_query_acceleration_time DESC;

      Why: This ranks last week's queries by how much of their run time QAS could take over.

      You should see: A list of query IDs. An empty result means no recent query was eligible.

    2. 2.Pass the top query ID to SELECT PARSE_JSON(SYSTEM$ESTIMATE_QUERY_ACCELERATION('<query_id>'));

      Why: This shows the estimated run time at each scale factor before you spend anything.

      You should see: status 'eligible' with estimatedQueryTimes per scale factor, or 'ineligible' with an ineligibleReason.

    3. 3.Run ALTER WAREHOUSE <warehouse_name> SET ENABLE_QUERY_ACCELERATION = true; and set QUERY_ACCELERATION_MAX_SCALE_FACTOR to the point where the estimates level off.

      Why: The scale factor sets the most extra credits QAS can spend.

      You should see: The statement succeeds.

    4. 4.Run SHOW WAREHOUSES LIKE '<warehouse_name>' ->> SELECT "name", "enable_query_acceleration", "query_acceleration_max_scale_factor" FROM $1;

      Why: This confirms both settings took effect.

      You should see: enable_query_acceleration is true, and the scale factor is the value you chose.

    Stuck? Get a nudge

    Remember that an ACCOUNT_USAGE view can lag by up to 45 minutes, so a query you ran just now may not appear yet.

    Sources

    (8)

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

    1. 1.
      “Snowflake resets the 24-hour retention period for the result, up to a maximum of 31 days from the date and time”
      ↩︎ The result cache: persisted query results
      “UUID_STRING, RANDOM, and RANDSTR are good examples of non-reusable functions.”
      ↩︎ The result cache: persisted query results
      “can be overridden at the account, user, and session level using the USE_CACHED_RESULT session parameter.”
      ↩︎ The result cache: persisted query results
      “For persisted query results of all sizes, the cache expires after 24 hours.”
      ↩︎ Exam trap 1
      “Any difference in syntax, including lowercase versus uppercase, or the use of table aliases, will inhibit 100% cache reuse.”
      ↩︎ Exam trap 2
      “Any difference in syntax, including lowercase versus uppercase, or the use of table aliases, will inhibit 100% cache reuse.”
      ↩︎ Checkpoint
    2. 2.
      “Snowflake recommends setting auto-suspend to at least 10 minutes to maintain the cache for users.”
      ↩︎ Warehouse cache, metadata answers and AUTO_SUSPEND
      “Keep in mind that a running warehouse consumes credits even if it is not processing queries.”
      ↩︎ Warehouse cache, metadata answers and AUTO_SUSPEND
      “the cache is dropped when the warehouse is suspended.”
      ↩︎ Prediction
    3. 3.
      “A query whose result is computed based purely on metadata, without accessing any data.”
      ↩︎ Warehouse cache, metadata answers and AUTO_SUSPEND
      “These queries are not processed by a virtual warehouse.”
      ↩︎ Warehouse cache, metadata answers and AUTO_SUSPEND
    4. 4.
      “Point lookup queries are queries that are expected to return a small number of rows.”
      ↩︎ Search optimization, materialized views or clustering
    5. 5.
      “In general, enabling search optimization only for specific columns is the best practice.”
      ↩︎ Search optimization, materialized views or clustering
    6. 6.
      “Materialized views improve performance only for the subset of rows and columns included in the materialized view.”
      ↩︎ Search optimization, materialized views or clustering
      “A table can be clustered only on a single key, which can contain one or more columns or expressions.”
      ↩︎ Search optimization, materialized views or clustering
      “Search optimization and query acceleration can work together to optimize query performance.”
      ↩︎ The query acceleration service and its scale factor
      “You can also use materialized views to define different clustering keys on the same source table, or a subset of that table”
      ↩︎ Checkpoint
    7. 7.
      “For optimal performance when querying large data files, create and query materialized views over external tables.”
      ↩︎ Search optimization, materialized views or clustering
      “query response time is faster when processing a small part of the data instead of scanning the entire data set.”
      ↩︎ Search optimization, materialized views or clustering
    8. 8.
      “it can improve overall warehouse performance by reducing the impact of outlier queries”
      ↩︎ The query acceleration service and its scale factor
      “Large scans with an aggregation or selective filter.”
      ↩︎ The query acceleration service and its scale factor
      “The scale factor is a cost control mechanism that allows you to set an upper bound on the amount of compute resources”
      ↩︎ The query acceleration service and its scale factor
      “To identify the queries or warehouses that might benefit from the query acceleration service, you can query the QUERY_ACCELERATION_ELIGIBLE view.”
      ↩︎ The query acceleration service and its scale factor
      “Setting the scale factor to 0 eliminates the upper bound limit”
      ↩︎ Exam trap 3
      “Setting the scale factor to 0 eliminates the upper bound limit and allows queries to lease as many resources as necessary and as available”
      ↩︎ Checkpoint

    Ready to test yourself?

    Practise the 14 questions on this subdomain.

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