Performance triage in Snowflake starts at the query level, not the warehouse level. A query that is slow on an XL warehouse will rarely be cured by promoting to 2XL if the root cause is a missing predicate, an exploding join, or a spill that the next size up will only partially absorb. The DEA-C02 exam treats this section as the entry point into the entire performance domain: every other tuning lever in the chapter (clustering, Materialized Views, caching, Query Acceleration Service) presupposes that you have first read the telemetry correctly.
How it works
The primary telemetry surface is the Query Profile, exposed through the Snowsight Activity > Query History panel and through the GET_QUERY_OPERATOR_STATS table function.
The profile shows the physical plan as a tree of operators (TableScan, Filter, Join, Aggregate, Sort, Result), each with its own duration, percentage of execution time, partitions scanned, partitions pruned, bytes spilled to local storage, and bytes spilled to remote storage.
The two pieces of data most often missed by candidates are:
- The Partitions scanned vs. partitions total ratio at every TableScan.
- The Bytes spilled to remote storage counter at every operator.
Remote spill is the single most reliable indicator that the warehouse is undersized for the working set. A query that completes in twenty minutes with two terabytes of remote spill will often complete in three minutes at the next size up because remote spill is paid as both extra IO and extra compute time, not just IO.
Building a triage funnel from the QUERY_HISTORY view
The repeatable workflow is to start from SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY (or the INFORMATION_SCHEMA.QUERY_HISTORY table function for the live last fourteen days), filter the candidates, then drill into Query Profile only for the worst offenders.
The filter that surfaces the highest-impact queries combines TOTAL_ELAPSED_TIME, BYTES_SPILLED_TO_REMOTE_STORAGE, and PARTITIONS_SCANNED / PARTITIONS_TOTAL ratio.
A query that scans 100% of partitions on a multi-terabyte table is almost always a pruning failure, regardless of how fast it returns; a fast scan of a small table is not interesting.
SELECT query_id,
user_name,
warehouse_name,
warehouse_size,
total_elapsed_time / 1000 AS elapsed_seconds,
bytes_scanned / POWER(1024, 3) AS gb_scanned,
partitions_scanned,
partitions_total,
ROUND(partitions_scanned / NULLIF(partitions_total, 0) * 100, 2) AS pct_scanned,
bytes_spilled_to_local_storage / POWER(1024, 3) AS local_spill_gb,
bytes_spilled_to_remote_storage / POWER(1024, 3) AS remote_spill_gb,
execution_status,
query_text
FROM snowflake.account_usage.query_history
WHERE start_time >= DATEADD(day, -7, CURRENT_TIMESTAMP())
AND total_elapsed_time > 60000
AND warehouse_name = 'PIPELINE_WH_L'
ORDER BY total_elapsed_time DESC
LIMIT 50;
For each candidate query, expand the Query Profile and read it from the bottom up.
- The first TableScan operator in the tree is usually the largest source of work, and its "Partitions scanned" field tells you whether pruning is working.
- The second pattern to look for is a Join operator with a "Cardinality" output far larger than either of its inputs.
- This signals a missing join key, a Cartesian join hidden behind an OR condition, or a one-to-many fan-out that the original developer did not anticipate.
- The third pattern is a Sort or Aggregate operator with non-zero "Bytes spilled to remote storage".
Sort spills typically come from ORDER BY clauses that lack a LIMIT; aggregate spills come from GROUP BY cardinalities that exceed the per-node memory budget.
💡 Exam Trap: A high
BYTES_SCANNEDvalue alone is not a tuning signal. Snowflake reports compressed bytes scanned from cloud storage, which can be artificially low after a result cache hit (zero scan) or artificially high during cold reads. Always pairBYTES_SCANNEDwithPARTITIONS_SCANNED / PARTITIONS_TOTALto distinguish a cold cache from a pruning failure.
📊 Limit:
INFORMATION_SCHEMA.QUERY_HISTORYretains 14 days of data and is bounded by the calling role's session.SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORYretains 365 days with a typical latency of up to 45 minutes from query end time. Choose ACCOUNT_USAGE for post-mortem analysis and INFORMATION_SCHEMA for real-time alerting on warehouses owned by the current role.
Reading the Query Profile operator graph
Beyond the column-level statistics, the Query Profile exposes operator-level metadata that pinpoints the root cause without guesswork.
The GET_QUERY_OPERATOR_STATS function returns one row per operator with OPERATOR_TYPE, OPERATOR_STATISTICS (a VARIANT with type-specific counters), and EXECUTION_TIME_BREAKDOWN.
- For a TableScan operator, look at
OPERATOR_STATISTICS:pruning.partitions_scannedandOPERATOR_STATISTICS:pruning.partitions_total. - For a Join operator, look at
OPERATOR_STATISTICS:join.cardinality_output. - For an Aggregate, look at
OPERATOR_STATISTICS:aggregate.cardinality_inputandcardinality_output.
These figures are not visible in the simple QUERY_HISTORY columns and are what separates intermediate-level guesswork from advanced-level diagnosis.
SELECT operator_id,
parent_operator_id,
operator_type,
operator_statistics,
execution_time_breakdown,
operator_attributes
FROM TABLE(get_query_operator_stats('01b1a2c3-0000-1234-0000-000000000001'))
ORDER BY operator_id;
Three operator-level patterns recur on the exam: a JoinFilter that does not appear under a Join operator (indicating that runtime dynamic pruning did not engage), a CartesianJoin that the optimizer chose because no join predicate could be derived, and an ExternalScan with a long EXECUTION_TIME_BREAKDOWN:remote_disk_io segment (indicating that an external table or Iceberg table is the bottleneck rather than native storage).
Monitor continuous pipelines using Tasks, Streams, Snowpipe Streaming, Alerts, and Dynamic Tables
Continuous pipelines have their own telemetry surfaces that mirror but do not duplicate QUERY_HISTORY.
Each pipeline object publishes its execution history to a dedicated view:
- Tasks publish to
TASK_HISTORY - Streams expose freshness through
SYSTEM$STREAM_HAS_DATAandSYSTEM$STREAM_GET_TABLE_TIMESTAMP - Snowpipe Streaming publishes to
SNOWPIPE_STREAMING_FILE_MIGRATION_HISTORYandSNOWPIPE_STREAMING_CLIENT_HISTORY - Alerts publish to
ALERT_HISTORY - Dynamic Tables publish to
DYNAMIC_TABLE_REFRESH_HISTORYandDYNAMIC_TABLE_GRAPH_HISTORY
Each view exposes a different combination of duration, error code, error message, and a state column whose values change across object types.
For Tasks, the workflow is to query TASK_HISTORY for a specific task name and root task graph, filter on STATE in ('FAILED', 'CANCELLED', 'SKIPPED'), then correlate the failed task's QUERY_ID back to QUERY_HISTORY for the underlying SQL.
A common pipeline failure pattern is a SKIPPED state propagating down a DAG because a parent task succeeded with zero rows and a downstream task's WHEN predicate evaluated to false; this is not a bug but does need to be acknowledged in monitoring or it will mask real failures.
SELECT name,
database_name,
schema_name,
scheduled_time,
completed_time,
state,
error_code,
error_message,
query_id,
run_id,
root_task_id
FROM snowflake.account_usage.task_history
WHERE scheduled_time >= DATEADD(hour, -24, CURRENT_TIMESTAMP())
AND root_task_id = '01b1a2c3-aaaa-bbbb-cccc-000000000001'
AND state IN ('FAILED', 'CANCELLED', 'SKIPPED')
ORDER BY scheduled_time DESC;
For Streams, the relevant telemetry is freshness, not throughput.
SYSTEM$STREAM_HAS_DATA('order_stream') returns a boolean indicating whether the stream has unconsumed offsets; SYSTEM$STREAM_GET_TABLE_TIMESTAMP('order_stream') returns the timestamp of the oldest unconsumed change.
The freshness window for a stream is bounded by the source table's DATA_RETENTION_TIME_IN_DAYS.
If a stream is not consumed within that window, it becomes stale and queries against it raise an error until it is recreated.
Monitoring code should compare the stream's offset timestamp against the table's data retention setting and alert before the window closes, not after.
In practice
For Snowpipe Streaming, the high-cardinality telemetry sits in SNOWPIPE_STREAMING_CLIENT_HISTORY, which records per-client throughput, latency, and error counts.
The metric to watch is AVG_LATENCY_MS per channel, which captures the time from insertRow to row visibility in the target table.
If average latency drifts above the configured target (typically under 10 seconds for a properly sized account), the root cause is usually channel skew (one channel handling disproportionate volume) rather than aggregate volume.
Snowpipe Streaming auto-creates channels per client; monitoring by channel rather than by pipe is the only way to spot skew.
SELECT pipe_name,
channel_name,
start_time,
end_time,
rows_inserted,
rows_parsed,
bytes_inserted,
avg_latency_ms,
p99_latency_ms
FROM snowflake.account_usage.snowpipe_streaming_client_history
WHERE start_time >= DATEADD(hour, -1, CURRENT_TIMESTAMP())
ORDER BY p99_latency_ms DESC;
Alerts in Snowflake are themselves monitored through ALERT_HISTORY.
The history captures SCHEDULED_TIME, COMPLETED_TIME, STATE (one of SCHEDULED, EXECUTED, SUCCEEDED, FAILED, CONDITION_FAILED, SKIPPED), and the underlying CONDITION_TEXT and ACTION_TEXT.
A common failure mode is CONDITION_FAILED, which means the alert condition itself raised an error (for example, a missing table), not that the underlying data condition was met.
Treating CONDITION_FAILED as equivalent to SUCCEEDED silently disables the alert, which is a serious operational risk.
Dynamic Tables expose two views: DYNAMIC_TABLE_REFRESH_HISTORY and DYNAMIC_TABLE_GRAPH_HISTORY.
The refresh history records per-refresh duration, rows added, rows updated, and rows deleted; the graph history records the dependency structure of the refresh DAG and the order in which downstream tables refreshed.
The metric to watch is the gap between TARGET_LAG (the declared SLO) and DATA_TIMESTAMP (the actual observed lag).
A Dynamic Table that drifts above its target lag for several consecutive intervals usually has a refresh duration approaching the target, meaning the warehouse cannot complete the incremental refresh in time.
The remedy is either to scale up the warehouse, simplify the query, or relax the target lag.
🎯 Scenario: A Dynamic Table named
gold_customer_metricsis configured withTARGET_LAG = '1 minute'over an upstream table receiving 50,000 rows per second through Snowpipe Streaming. After two days,DYNAMIC_TABLE_REFRESH_HISTORYshows refresh durations averaging 90 seconds on a Medium warehouse. The lag has drifted to 2.5 minutes. The root cause is that the refresh interval cannot complete within the target. Either scale to Large to halve refresh time, changeREFRESH_MODEtoFULLif the incremental cost is dominated by change detection overhead, or relaxTARGET_LAGto 3 minutes to match capacity.
⚠️ Anti-Pattern: Pointing every continuous pipeline at the same warehouse and then expecting per-pipeline performance tuning to work. Co-tenancy on a single warehouse hides per-pipeline bottlenecks under aggregate queue depth and makes Query Acceleration Service decisions impossible. Allocate one warehouse per pipeline tier (ingest, transform, serve) at minimum, and use multi-cluster scaling for the serve tier only.
Decision Anchor
When to use
- Choose Query Profile drill-down when you have a single slow query and need to identify the operator-level root cause.
- Choose QUERY_HISTORY aggregate filtering when you need to find the worst queries across a warehouse over a time window.
- Choose the pipeline-specific history views (TASK_HISTORY, DYNAMIC_TABLE_REFRESH_HISTORY, SNOWPIPE_STREAMING_CLIENT_HISTORY) when the slow object is a continuous pipeline rather than an ad-hoc query, because QUERY_HISTORY shows only the SQL that the pipeline emitted, not the pipeline state machine around it.
