Module 20 · Lesson 3 of 11Detailed study · about 29 min

Snowflake Query and Warehouse Monitoring: Queues, Spills and Blocked Transactions

Find running and failed SQL, separate compilation, execution and waiting time, and use warehouse load to choose the right fix.

Before you beginUnderstand the available histories

Break a slow query into stages

A query can wait for resources before doing any work. Snowflake then plans the operation and runs it. Recorded timings help separate one big elapsed time into useful clues. For example, queued provisioning time can reflect compute starting or resizing. Queued overload time points to too much competing work for available warehouse resources. Transaction-blocked time can point to a write waiting on another transaction.

These timings are diagnostic fields, not a promise that the metrics you selected sum to elapsed time. Use Snowsight Query History for live activity and Query Profile for an operator-by-operator view once the profile is available. A profile can show which join or sort spilled, while the history tells you whether it was worth opening the profile in the first place.

Representative completed query results from the same morning
Query IDElapsed msCompile msExecute msOverload msBlocked msRemote spill bytes
q-queue95,0001,0008,00085,00000
q-lock95,0001,00015,000078,0000
q-spill95,0002,00092,00000204,800,000
Choose the right evidence for a slow statement Query timing fields can overlap or omit work. Treat these paths as diagnostic choices.
  1. Slow statementOverload wait to Warehouse overload queue
  2. Slow statementBlocked time to Blocked on a transaction
  3. Slow statementExecution time to Processing and spill
Slow statement
Start with elapsed time and the query ID.
Warehouse overload queue
Check competing jobs and warehouse load for the same interval.
Blocked on a transaction
Check the visible lock holder and coordinate with its owner.
Processing and spill
Open Query Profile and find the expensive operation.

Find active, failed and long-running statements

Use a role with access to the relevant queries and an approved warehouse. QUERY_HISTORY shows your visible activity. Monitoring another user’s warehouse queries requires the applicable warehouse or account privilege. Read the visibility rules before assuming that a missing query has ended. The function may show ongoing statuses, and the Account Usage view is intended for historical reporting. For an active query, compare its start to the current clock rather than treating final elapsed and spill metrics as settled.

A run can fail because of missing permissions, a bad cast or a warehouse problem. Read ERROR_MESSAGE for the specific query ID. SQL text may contain sensitive values. Redact it before putting it in a ticket. For client cancellations, also read the error fields because cancellation is not a separate EXECUTION_STATUS value in the history function.

SQL · configuration template
SELECT query_id, execution_status, start_time,
       DATEDIFF('second', start_time, CURRENT_TIMESTAMP()) AS age_seconds,
       error_code, error_message
FROM TABLE(LS_M20_OPS_LAB.INFORMATION_SCHEMA.QUERY_HISTORY(
  END_TIME_RANGE_START => DATEADD('hour', -1, CURRENT_TIMESTAMP()),
  RESULT_LIMIT => 1000
))
ORDER BY start_time DESC LIMIT 50;

SELECT query_id, execution_status, total_elapsed_time, compilation_time, execution_time,
       queued_provisioning_time, queued_overload_time, transaction_blocked_time,
       bytes_spilled_to_local_storage, bytes_spilled_to_remote_storage, error_message
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
WHERE warehouse_name = 'MAPLE_WH'
  AND start_time >= DATEADD('day', -1, CURRENT_TIMESTAMP())
ORDER BY total_elapsed_time DESC LIMIT 20;

Check warehouse pressure and confirm the suspected cause

Warehouse load shows the average running, queued and blocked load over time. Load values describe activity over an interval. They are neither an instantaneous query count nor percentage CPU utilization. An average overload queue of 0.40 means queued work occupied part of that interval. Match the query’s start and warehouse to the same load interval.

If a job is blocked now, an authorized role can inspect SHOW LOCKS and SHOW TRANSACTIONS. Visibility depends on the role. Compare the lock’s transaction and status with the other session and ask its owner to finish safely. An administrator should follow the team’s incident process before interrupting a transaction because uncommitted work can be discarded.

For remote spill, check the slow operator in Query Profile, then test reducing rows early or fixing joins that multiply rows. Compare the same query on a larger warehouse only when memory is still the limiting factor. For repeated overload, stagger jobs, isolate workloads or consider multi-cluster scaling where available. For rising credits with flat traffic, compare metering with baseline, warehouse changes and job duration. Credits alone cannot identify the cause.

Representative observations and the evidence to collect next
ObservationNext step
07:45 load interval: 3.00 running, 0.40 queued, 0.00 blockedCompare start times of overlapping jobs and test staggering them.
A waiting transaction and a holder appear for the same objectTrace the holder’s session and coordinate with its owner.
Only one statement has high remote spillFind its spilling operator before tuning the entire warehouse.
SQL · configuration template
SHOW LOCKS;
SHOW TRANSACTIONS;

SELECT start_time, end_time, warehouse_name, avg_running, avg_queued_load,
       avg_queued_provisioning, avg_blocked
FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_LOAD_HISTORY
WHERE warehouse_name = 'MAPLE_WH'
  AND start_time >= DATEADD('day', -1, CURRENT_TIMESTAMP())
ORDER BY start_time DESC LIMIT 20;

Interview practice

Explain the decision and the evidence you would use to test it.

Beginner · What is a spilled byte?

It is part of an intermediate result Snowflake wrote to storage because memory was insufficient for that part of the work. I locate the operator before changing the warehouse.

SQL · How would you identify a blocked query?

I find the visible running statement and inspect locks while the wait is happening. For past work I compare TRANSACTION_BLOCKED_TIME with elapsed time and correlate the timestamps.

Production · When would you scale out versus tune SQL?

If many otherwise healthy statements queue together, I investigate concurrency and workload isolation first. If one statement spills or multiplies rows, I inspect its plan and test a SQL or sizing improvement. Then I compare latency and credits with a baseline.

Words used in this lesson
Query ID
The unique identifier Snowflake assigns a statement.
Compilation
Work to check a SQL statement and choose its execution plan.
Concurrency
How much work arrives or runs at the same time.
Spill
Intermediate data written to local or remote storage when available memory is insufficient.
Lock
A concurrency safeguard that can make one transaction wait while another changes data.

Try the SQL or command

Read → predict → run in your learning environment → compare. You can also learn by reading without an account.

Use the SQL and expected outputs in the sections above.

New to SQL? Where to run it and how to read it

A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.

  1. No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
  2. For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
  3. Read the entire example, including comments beginning with --. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor.
  4. Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
SELECT / FROM
Choose the values to return / identify their input.
VALUES / COLUMN1
VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
AS / WITH
AS gives a result a readable name. WITH names a temporary query step within one statement.
NULL / ::
NULL means missing or unknown. The :: notation converts a value to a named data type.
Session
One connection and its settings. Keep related transaction steps in the same session.
Database.schema.table
A full address for stored data. It is separate from the warehouse that processes queries.

Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →

Help with common practice errors
  • No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
  • Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
  • Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
  • Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.

Before running this lesson

Maple Market is fictional. Output tables are representative. Live commands require an authorized test account and the roles, compute and edition listed in each lesson.

Check your understanding

Choose an answer, then check your reasoning. This is practice, not a scored test.

A completed statement shows 78 seconds of transaction-blocked time. Which evidence should you look for next?

Try it yourself

Overload wait rose at 07:45 while CPU-heavy query shapes stayed similar. What trial would you run?

Compare your reasoning

Compare batch windows and moving competing work to a separate warehouse. With supported multi-cluster settings, test concurrency scaling. Measure queue time and compute credits before and after.

Connect this lesson to the learning path

Official sources and curriculum

Module 20 · See module scope

By Rohit Ray · Independent educational lesson · Explore this visual lab