MockCertMockCert
Menu
Domain 4 · 4 topics · about 25 minTopics in this domainTopics

Domain 4 · Overview

Overview

Study guide PDF
Share
LinkedInWhatsAppX

This domain is about 21% of the exam, roughly 21 of its 100 questions.

Every point below comes from Snowflake's official documentation; each section lists its sources.

Up next: Evaluate query performance · 11 steps + check · 6 min

Domain 4 · Topic 1 of 4

Evaluate query performance

Study guide PDF
Share
LinkedInWhatsAppX

Step 1 of 11

Think first A query is slow or costly: which QUERY_HISTORY column, query insight or Account Usage view shows you why?

Why it matters: Questions describe a slow or costly query and ask which column, insight or view reveals the cause.

QUERY_HISTORY records each query's spilling, pruning and queuing. QUERY_INSIGHTS turns problems into labeled insights, one row each. QUERY_ATTRIBUTION_HISTORY shows what each query cost on a warehouse.

Step 2 of 11

Term Meaning
Remote spillage Data a query spilled to remote disk, shown in bytes_spilled_to_remote_storage.
Pruning How many micro-partitions a query avoids reading; compare partitions scanned with the total.
Exploding join A join problem flagged by QUERY_INSIGHT_EXPLODING_JOIN under the JOIN insight topic.
Queued overload Time a query waited in the queue because the warehouse was overloaded.
Adaptive Warehouse A warehouse kind other than a standard warehouse, with its own view for per-query credit usage.

Step 3 of 11

QUERY_HISTORY shows spilling, pruning and queuing for each query. bytes_spilled_to_remote_storage shows data spilled to remote disk. Compare partitions_scanned with partitions_total to judge pruning. The view covers 365 days, while the Information Schema function covers only 7.

Exam trap Not every query in QUERY_HISTORY also appears in ACCESS_HISTORY. When you query ACCESS_HISTORY, filter on query_start_time with a narrow range.

Step 4 of 11

Two queue time columns show why a query waited. Overload means the current workload is too much for the warehouse. Provisioning means the warehouse was still being created, resumed or resized.

Two queue time columns compared

Feature queued_overload_time QUEUED_PROVISIONING_TIME
Why the query waits The warehouse is overloaded by the current workload Compute is provisioning after creation, resume or resize
Unit Milliseconds Milliseconds

Step 5 of 11

QUERY_INSIGHTS holds one row per insight produced for a query. Remote spillage and queued overload appear under the WAREHOUSE topic. Exploding joins appear under the JOIN topic, as QUERY_INSIGHT_EXPLODING_JOIN or QUERY_INSIGHT_NESTED_EXPLODING_JOIN.

Step 6 of 11

Pruning history views help you choose clustering keys. A good cluster key means fewer micro-partitions to scan for filters, joins and aggregates. TABLE_QUERY_PRUNING_HISTORY finds the tables queries access, and COLUMN_QUERY_PRUNING_HISTORY finds their often-used columns. Its ACCESS_TYPE column shows WHERE or JOIN use. TABLE_PRUNING_HISTORY compares pruning before and after Automatic Clustering or search optimization.

Exam trap COLUMN_QUERY_PRUNING_HISTORY reflects the plan actually executed, not your SQL text, so a HAVING clause can show as WHERE. It has no data for hybrid tables.

Step 7 of 11

QUERY_ATTRIBUTION_HISTORY shows each query's warehouse compute cost. Use it for standard warehouses. Attributed credits leave out warehouse idle time. For an accelerated query, add CREDITS_USED_QUERY_ACCELERATION to CREDITS_ATTRIBUTED_COMPUTE for the total.

Exam trap Queries of about 100 ms or less never appear in QUERY_ATTRIBUTION_HISTORY. They are too short for per-query cost attribution.

Step 8 of 11

Adaptive Warehouse queries use QUERY_METERING_HISTORY instead. It gives per-query credits for 365 days, with one row per metering hour while a query runs. Charges can take up to 1 hour to appear. Roles granted USAGE_VIEWER or GOVERNANCE_VIEWER can see it.

Step 9 of 11

AGGREGATE_QUERY_HISTORY groups repeated statements by the minute. It holds data like QUERY_HISTORY, aggregated in one-minute intervals. It suits high-throughput workloads that repeat a few distinct statements, such as Unistore workloads. Queries that differ only in literal values can share one QUERY_PARAMETERIZED_HASH.

Step 10 of 11

Account Usage views lag by different amounts. Check a view's latency before you decide that a recent query is missing from it.

Latency of the main query views

View Latency What it covers
QUERY_HISTORY Up to 45 minutes Each query, for 365 days
QUERY_INSIGHTS Up to 90 minutes One row per insight
QUERY_ATTRIBUTION_HISTORY Up to 8 hours Compute cost per query
TABLE_PRUNING_HISTORY Up to 6 hours Pruning for each table
COLUMN_QUERY_PRUNING_HISTORY Up to 4 hours Column access, kept for 1 year

Step 11 of 11

  • Remote spilling shows in bytes_spilled_to_remote_storage; pruning shows in partitions scanned against the total.
  • Queued overload means a busy warehouse; queued provisioning means compute was still starting or resizing.
  • QUERY_ATTRIBUTION_HISTORY leaves out idle time and queries of about 100 ms or less.
  • Account Usage QUERY_HISTORY keeps 365 days; the Information Schema function keeps 7.

Sources: QUERY_HISTORY view | Snowflake Documentation · QUERY_INSIGHTS view | Snowflake Documentation · QUERY_ATTRIBUTION_HISTORY view | Snowflake Documentation · TABLE_PRUNING_HISTORY view | Snowflake Documentation · QUERY_METERING_HISTORY view | Snowflake Documentation · ACCESS_HISTORY view | Snowflake Documentation · AGGREGATE_QUERY_HISTORY view | Snowflake Documentation · Optimizing storage for performance | Snowflake Documentation

Check

Check: Evaluate query performance

Cards to recall, then questions on this topic. About 2 minutes. Nothing is saved without an account.

Loading the cards and questions…

Up next: Optimize query performance · 10 steps + check · 6 min

Domain 4 · Topic 2 of 4

Optimize query performance

Study guide PDF
Share
LinkedInWhatsAppX

Step 1 of 10

Think first A query runs slowly: when do you reach for query acceleration, search optimization, a clustering key or a materialized view?

Why it matters: Questions describe a slow query or table and ask which performance feature, setting, cost or limit fits it.

Each feature speeds up a different kind of query. Query acceleration offloads parts of large outlier queries to shared compute, and search optimization builds a search access path for point lookups. Clustering keys co-locate data in micro-partitions, and the optimizer can swap in a materialized view for its base table.

Step 2 of 10

Term Meaning
Query acceleration service Offloads portions of outlier queries to shared compute resources that the service provides.
Search access path The persistent data structure that search optimization builds and maintains to speed up searches.
Clustering key Columns or expressions chosen to co-locate a table's data in the same micro-partitions.
Point lookup A selective query that finds just one row or a few distinct rows.
Analyzer A setting named in the ALTER TABLE command for FULL_TEXT search optimization and again in the SEARCH function call.

Step 3 of 10

Query acceleration suits large scans with a selective filter or aggregation. It also helps large scans that insert or copy many new rows. Turn it on with ENABLE_QUERY_ACCELERATION = TRUE on CREATE WAREHOUSE or ALTER WAREHOUSE. Gen2 standard and multi-cluster warehouses have it on by default. Its total cost is the warehouse plus the service.

Exam trap Queries with nondeterministic functions such as SEQ or RANDOM are not eligible. A query with LIMIT also needs ORDER BY to qualify.

Step 4 of 10

SYSTEM$ESTIMATE_QUERY_ACCELERATION tests whether one query is eligible. The QUERY_ACCELERATION_ELIGIBLE view finds queries and warehouses that might benefit. The two services can also work together: search optimization prunes micro-partitions first, then query acceleration offloads part of the remaining work.

Step 5 of 10

Search optimization targets selective point lookups. It works best when a filtered column has about 100,000 or more distinct values. Queries that already run in under a second rarely gain much. The optimizer decides when to use it, and a query needs only SELECT on the table.

Example: Adds search optimization to a whole table.

ALTER TABLE my_table ADD SEARCH OPTIMIZATION;
  • ADD SEARCH OPTIMIZATION: with no ON clause, columns added later also get EQUALITY

Step 6 of 10

External, hybrid and temporary tables are not supported. Queries that use Time Travel gain nothing, because it works only on active data. FLOAT, DECFLOAT and GEOMETRY values do not benefit, and neither do most predicates that cast the column's values.

Exam trap FULL_TEXT search optimization serves the SEARCH function, and its ALTER TABLE command names an analyzer. The SEARCH call names an analyzer too. If the two differ, the search access path is not used.

Step 7 of 10

Maintenance needs no warehouse of yours, but it is not free. Its storage and compute are charged. SYSTEM$ESTIMATE_SEARCH_OPTIMIZATION_COSTS gives an estimate, but real costs can differ by up to 50%. The access path is usually about 1/4 of the table's size. Enabling specific columns, not the whole table, is the usual best practice.

Exam trap On a high-churn table, adding Automatic Clustering to search optimization can raise maintenance costs above search optimization alone.

Step 8 of 10

Keep a clustering key to 3 or 4 columns or expressions. More columns tend to add cost faster than benefit. Clustering pays off most on tables that are queried often and change rarely.

Clustering compared with search optimization

Feature Clustering Search optimization
Best for Range queries and inequality filters Selective point lookups
How it helps Co-locates data in the same micro-partitions Builds and maintains a search access path
Scope on a table One clustering key per table Best enabled for specific columns

Step 9 of 10

A materialized view can query only one table. Joins, including self-joins, are not supported. The optimizer can rewrite base-table queries to use the view automatically. Materialized views can also speed up queries on external tables and let you cluster the same data on a different key.

Exam trap A materialized view that is behind its base table still returns up-to-date results. The query may just take a little longer.

Step 10 of 10

Check

Check: Optimize query performance

Cards to recall, then questions on this topic. About 2 minutes. Nothing is saved without an account.

Loading the cards and questions…

Up next: Use Snowflake caching · 10 steps + check · 6 min

Domain 4 · Topic 3 of 4

Use Snowflake caching

Study guide PDF
Share
LinkedInWhatsAppX

Step 1 of 10

Think first When does Snowflake reuse a cached result, and when does a warehouse setting throw a cache away?

Why it matters: Questions describe a query or a warehouse setting and ask whether a cache is reused, lost or worth keeping.

Snowflake persists query results for reuse, and each running warehouse caches table data. Result reuse needs an exactly matching query. The warehouse cache is dropped when the warehouse suspends, so auto-suspend trades saved credits against speed.

Step 2 of 10

Term Meaning
Query result cache Persisted results Snowflake can reuse; each reuse resets 24 hours, up to 31 days.
Warehouse cache Table data a running warehouse keeps for later queries on the same warehouse.
USE_CACHED_RESULT The parameter that overrides result reuse at the account, user or session level.
RESULT_SCAN A table function that returns an earlier query's results as a table.
Interactive warehouse A warehouse you attach interactive tables to, up to 100, so it can warm a cache for those tables.

Step 3 of 10

Result reuse needs the new query to match the old one exactly. Even a change in letter case or a table alias stops full reuse. Reuse is on by default, and USE_CACHED_RESULT can override it for an account, user or session.

Exam trap Functions such as UUID_STRING, RANDOM and RANDSTR block reuse. So do external functions and queries on hybrid tables.

Step 4 of 10

Persisted results expire after 24 hours. Each reuse resets the 24 hours, up to 31 days from the first run. For results over 100 KB, the access token expires after 6 hours. A cached SHOW result is reused only by the role that produced it.

Step 5 of 10

RESULT_SCAN turns an earlier result into a table you can query. With no argument, it reads the most recent command. It works on results from any of your sessions within 24 hours, a period you cannot adjust. Add ORDER BY when row order matters.

Exam trap Even ACCOUNTADMIN cannot use RESULT_SCAN on another user's results. For manual queries, access belongs to the user who ran them, not the role.

Step 6 of 10

Some metadata commands, such as SHOW TABLES, need no warehouse. With no warehouse involved, no warehouse charges apply. To post-process SHOW output with RESULT_SCAN, double-quote the column names, because they are lowercase.

Step 7 of 10

A running warehouse caches table data for its own queries. Later queries on the same warehouse can read the cache instead of the tables. A larger warehouse has a larger cache. Suspending drops it, and after a resume some queries run slower until it is rebuilt.

Exam trap Resizing down also costs cache. The removed compute resources take their cache with them, much like a suspend.

Step 8 of 10

Set auto-suspend by how much the workload needs the cache. For tasks, suspend immediately. AUTO_SUSPEND is set in seconds and defaults to 600, which is 10 minutes. A value of 0 or NULL means the warehouse never suspends.

Suggested auto-suspend by workload

Workload Auto-suspend Cache value
BI and SELECT queries At least 10 minutes High: it keeps the cache for users
DevOps, DataOps and Data Science About 5 minutes Lower: queries are ad-hoc and unique

Exam trap AUTO_SUSPEND is not precise. The background process that suspends warehouses runs only about every 30 seconds.

Step 9 of 10

ALTER WAREHOUSE ... ADD TABLES starts cache warming. It attaches interactive tables to an interactive warehouse, up to 100 tables. A standard warehouse cache only rebuilds as queries run; this warms the cache for the chosen tables. DROP TABLES stops using the cache for those tables but does not drop the tables.

Step 10 of 10

  • Result reuse needs an exact query match; even a case or alias change prevents full reuse.
  • Persisted results last 24 hours, reset by each reuse up to 31 days.
  • Suspending or downsizing a warehouse drops its cache.
  • Keep BI warehouses running at least 10 minutes before suspending; ad-hoc ones about 5.

Sources: DESCRIBE RESULT | Snowflake Documentation · Optimizing the warehouse cache | Snowflake Documentation · Using Persisted Query Results | Snowflake Documentation · Warehouse considerations | Snowflake Documentation · ALTER WAREHOUSE | Snowflake Documentation · RESULT_SCAN | Snowflake Documentation

Check

Check: Use Snowflake caching

Cards to recall, then questions on this topic. About 2 minutes. Nothing is saved without an account.

Loading the cards and questions…

Up next: Perform data transformation techniques · 10 steps + check · 6 min

Domain 4 · Topic 4 of 4

Perform data transformation techniques

Study guide PDF
Share
LinkedInWhatsAppX

Step 1 of 10

Think first For a given data shape and result, how do you choose between aggregate and window functions, and handle VARIANT data or staged files?

Why it matters: Questions show a query, a data shape or a result and ask which function, clause or setting produces it.

An aggregate function returns one row per group, while a window function returns one row per input row. Semi-structured data sits in VARIANT, OBJECT and ARRAY columns. Unstructured files stay on a stage and are reached through scoped, file or pre-signed URLs, or FILE references.

Step 2 of 10

Term Meaning
Window function An analytic function that returns one row per input row, used for running totals, moving averages and rankings.
OVER clause Holds a window function's PARTITION BY, ORDER BY and window frame specification.
VARIANT null A real null value in semi-structured data that equals itself, unlike a missing SQL NULL.
Scoped URL A temporary URL to a staged file, made with BUILD_SCOPED_FILE_URL and usable only by its creator.

Step 3 of 10

Aggregates collapse a group; window functions keep every row. Use a window function for running totals, moving averages and rankings. An empty OVER() clause is valid.

Scalar, aggregate and window functions compared

Feature Scalar Aggregate Window
One result per Invocation, usually each row Group of rows Input row in a partition
Output One value One row per group One row per input row

Step 4 of 10

ORDER BY in OVER orders the window, not the query output. Ranking functions such as RANK and NTILE require it. Frames for running totals or moving averages need it too, or the frame is meaningless. Declare window frames explicitly instead of relying on an implied one.

Exam trap ORDER BY 2 inside OVER does not mean the second column. A number there is treated as the constant 2.

Step 5 of 10

In a RANGE frame, CURRENT ROW covers every row with the same ORDER BY value. A RANGE BETWEEN frame with explicit offsets must have exactly one ORDER BY expression. Correlated columns inside window functions, for example in PARTITION BY within a correlated subquery, are not supported.

Step 6 of 10

A VARIANT value holds up to 128 MB of uncompressed data. TYPEOF returns a stored value's native type. Dates and timestamps loaded from JSON are stored as strings, so they can be slower and larger than typed columns. Strings and dates come back in double quotes until you cast them.

Exam trap SQL NULL in a VARIANT means a missing value, while a VARIANT null is a real value. IS_NULL_VALUE tests JSON nulls, not SQL NULL.

Step 7 of 10

Array indexes start at 0. Reading past the end of an array returns NULL, not an error. ARRAY_SLICE returns elements from the start index up to, but not including, the end index. In an OBJECT, each key is a VARCHAR and each value is a VARIANT.

Step 8 of 10

Semi-structured and structured columns need the ON clause. Table-level search optimization covers neither kind. It can speed up point lookups that cast a semi-structured column to VARCHAR. Substring search uses only tokens of at least 5 characters, so LIKE '%TEST%' gains nothing.

Exam trap On a VARIANT column, enabling an element also covers its nested elements. On a structured column, nested elements are not covered.

Step 9 of 10

Unstructured files must sit on an internal or external stage. A FILE value stores only a reference to the file, and it does not change when the file does.

Three ways to reach a staged file

Feature Scoped URL File URL Pre-signed URL
Who can use it Only the user who generated it Roles with enough privileges on the stage Any user or application
Access needed No stage privileges; expires after 24 hours USAGE on an external stage, READ on an internal one No Snowflake login or token

Exam trap Internal stages encrypt files client-side by default, and the type cannot change later. If you want unstructured data access, consider server-side encryption at stage creation.

Step 10 of 10

  • Aggregates return one row per group; window functions return one row per input row.
  • ORDER BY inside OVER orders only the window, and RANK and NTILE require it.
  • Array indexes start at 0, and reading past the end returns NULL.
  • Search optimization on VARIANT, OBJECT or ARRAY columns needs the ON clause.

Sources: Analyzing data with window functions | Snowflake Documentation · Semi-structured data types | Snowflake Documentation · Speeding up queries of semi-structured data with search optimization | Snowflake Documentation · Unstructured data types | Snowflake Documentation · Introduction to unstructured data | Snowflake Documentation · REST API for unstructured data support | Snowflake Documentation · Window functions | Snowflake Documentation · Scalar functions | Snowflake Documentation

Check

Check: Perform data transformation techniques

Cards to recall, then questions on this topic. About 2 minutes. Nothing is saved without an account.

Loading the cards and questions…

Study guide PDF
Share
LinkedInWhatsAppX

Domain 4 · after the last topic

Domain 4 review

Each topic's Check tested it on its own; this mixes them.

Mixed quiz

Take the Domain 4 quiz

21 questions mixed from every topic in this domain, each answer explained. Mixing topics is harder than one at a time, and it is what the exam does. No account needed; with a free account your answers also build your estimated exam score.

Flashcards

Domain 4 flashcards

8 cards with this domain's key facts. Flip each one and check what you knew. No account needed.

Next domain · 10% of the examData Collaboration3 topics