To find why an AI analytics answer on Snowflake is slow, time the whole request in the application and tag every statement it sends with a request ID. Then join that tag to QUERY_HISTORY and read QUEUED_OVERLOAD_TIME, QUEUED_PROVISIONING_TIME, COMPILATION_TIME and EXECUTION_TIME separately. Whatever remains belongs to the application, including model calls and result fetching, because QUERY_HISTORY has no column for fetch time. Each interval has a different remedy, and warehouse resizing only addresses some of them.
One answer is usually several statements
People debugging a slow AI answer tend to open Query History, find the big SELECT, see that it took two seconds, and conclude that Snowflake is innocent. That can be right, and it still leaves most of the wait unexplained. An agent may run value lookups and metadata checks before the final query, then retry after a failed check, and each statement has its own queue, compile and execution time.
Measure the request, with many statements inside it. Snowflake cannot give you that unit by itself, since it has never heard of your request. You supply the link by setting the QUERY_TAG session parameter to a request ID before the statements run. QUERY_TAG is then recorded against each statement in the history, and you can gather them back together. If your connection pool reuses sessions, reset the tag on checkout, or one request’s statements will be filed under the previous request’s ID.
ALTER SESSION SET QUERY_TAG = 'answer:req-7f3a';
-- run the statements for this request
SELECT query_id,
query_type,
warehouse_name,
role_name,
queued_provisioning_time,
queued_repair_time,
queued_overload_time,
compilation_time,
transaction_blocked_time,
execution_time,
total_elapsed_time,
total_elapsed_time
- queued_provisioning_time - queued_repair_time - queued_overload_time
- compilation_time - transaction_blocked_time - execution_time AS unexplained_ms
FROM TABLE(INFORMATION_SCHEMA.QUERY_HISTORY(
END_TIME_RANGE_START => DATEADD('hour', -1, CURRENT_TIMESTAMP()),
RESULT_LIMIT => 1000))
WHERE query_tag = 'answer:req-7f3a'
ORDER BY start_time;Pick the right history source
Two sources carry these columns, and their differences catch people out during an incident. The INFORMATION_SCHEMA table function is the live one. It covers the last seven days, returns only your own user’s queries unless your role has MONITOR or OPERATE on the warehouse, and applies its arguments before your WHERE clause. The default RESULT_LIMIT is 100, so a filter on your tag only searches the most recent 100 queries. On a busy warehouse that returns an empty result that looks like a tagging bug. Raise the limit, up to 10,000.
The ACCOUNT_USAGE.QUERY_HISTORY view keeps 365 days and is the right place for trends, but it can lag by up to 45 minutes. Access to the shared SNOWFLAKE database is limited to ACCOUNTADMIN by default, so ask for this grant before you need it. A role change during an outage is a bad time to learn it is missing.
Use the unexplained_ms column as a check on your own reading. Snowflake’s reference describes TOTAL_ELAPSED_TIME only as elapsed time and does not promise that the component columns add up to it. Retry columns such as QUERY_RETRY_TIME and FAULT_HANDLING_TIME exist as well, so a large remainder is a prompt to look further before you explain it.
A worked timing sheet
Take one synthetic 20-second answer, with every figure invented for illustration. The final SELECT executed in 1.9 seconds. The warehouse queue added 4.2 seconds, and model calls before and after the query added 9.6 seconds between them.
Run the options against those numbers. Suppose doubling the warehouse halved execution time. Generous. That saves under a second of the 20, and it would do little for the queue, since Snowflake’s guidance says resizing is mainly for large or complex queries and is not intended for handling concurrency. A separate warehouse for this workload could remove most of the 4.2 seconds, if the competition is other work. A 20 percent faster model saves about 1.9 seconds. On this sheet the warehouse size is the least useful thing to change, and it is the change most teams try first.
Reading each interval
The queue columns deserve separate treatment because they have opposite fixes. Provisioning queue time typically shows up in the first few minutes after a warehouse resumes, so a high value on the first question of the morning points at your suspend settings. Overload queue time means other work holds the warehouse. Snowflake’s queue guidance is to separate the workloads onto different warehouses, or use a multi-cluster warehouse, which requires Enterprise Edition. The Economy scaling policy can itself cause queueing, since it favors saving credits over starting clusters.
| Column | What it means | First thing to try |
|---|---|---|
| QUEUED_PROVISIONING_TIME | Waiting for compute after a create, resume or resize | Review auto-suspend for interactive warehouses, weighing idle credits |
| QUEUED_OVERLOAD_TIME | Waiting because the current workload overloaded the warehouse | Separate the workload or add clusters; check the scaling policy |
| QUEUED_REPAIR_TIME | Waiting while compute is repaired | Note it and exclude the run from comparisons |
| COMPILATION_TIME | Compiling the statement | Compare the same query shape across runs; look at view depth and generated SQL size |
| TRANSACTION_BLOCKED_TIME | Blocked by a concurrent DML | Check what writes the same table during question hours |
| EXECUTION_TIME | Running the statement | Check PARTITIONS_SCANNED against PARTITIONS_TOTAL, then spill columns |
| No column | Fetching results, model calls, rendering | Measure in the application; Snowflake cannot see these |
Generated SQL and the result cache
Result reuse is where AI workloads differ most from dashboards, and the reason is easy to miss. Snowflake reuses a persisted result only when the new query matches the earlier one textually, and its documentation says that differences in case or table aliases can prevent it. A dashboard sends the same string every time. A model may alias a table o one day and orders the next. Two people asking the same question can therefore execute twice against unchanged data.
You can test how much this costs you. Group a week of history by QUERY_PARAMETERIZED_HASH, which is computed from the parameterized text, and look at how many distinct QUERY_TEXT values share each hash. Many spellings per hash suggests that normalizing formatting before submission is worth trying. Reuse has other conditions too: the underlying data must be unchanged, the running role needs privileges on the tables, and Snowflake says that meeting every condition still does not guarantee it.
Caching also spoils benchmarks. Compare two configurations where the second run reuses the first run’s results and you have measured the cache. Set USE_CACHED_RESULT to FALSE for the session when timing execution, and run a separate pass with it on to measure what people will experience on repeated questions. Don’t mix the two sets of numbers.
SELECT warehouse_name,
COUNT(*) AS statements,
APPROX_PERCENTILE(queued_overload_time, 0.95) AS p95_overload_ms,
APPROX_PERCENTILE(queued_provisioning_time, 0.95) AS p95_provisioning_ms,
APPROX_PERCENTILE(compilation_time, 0.95) AS p95_compile_ms,
APPROX_PERCENTILE(execution_time, 0.95) AS p95_execution_ms
FROM snowflake.account_usage.query_history
WHERE start_time >= DATEADD('day', -7, CURRENT_TIMESTAMP())
AND query_tag LIKE 'answer:%'
GROUP BY warehouse_name
ORDER BY p95_overload_ms DESC;Things to do this week
- Add the tagSet QUERY_TAG to a request ID on every statement and log the same ID with the application’s own start and finish times.
- Time the gapsRecord the start and end of model calls and of result fetching in the application, because these are invisible from the warehouse.
- Sample by identityMeasure with more than one role. Row access policies and different warehouses mean one person’s timing may not represent another’s.
- Report the tailTrack the 95th percentile by interval as well as the median. Cold starts and queues live in the tail, and an average hides them.
- Check the numbers after tuningCompare totals and row populations after any change. A faster query that lost records or sidestepped a policy is a defect.
Checking this on Nexatron
I won’t give a response-time figure for Nexatron here, because any number depends on your warehouse, data and question mix, and one fast sample would tell you little. We run each question under the user’s sign-in, so their roles and policies apply to the statements Nexatron sends, and the generated SQL is shown on the answer. That gives you enough to look the statement up in your own QUERY_HISTORY under the user’s user and role and apply this method. In a demonstration, bring one slow question and its reference result, and agree on a target for that workload before you start the clock.
Bring three business questions
Explore your sources, definitions, and review criteria with our team. Please keep credentials and sensitive records out of the inquiry.