Use query evidence to explain a slowdown
Trace the difference between queueing, spilling, poor pruning and join multiplication.
Use query evidence to explain a slowdown
Work through the decision
A dashboard now takes 80 seconds. History shows 50 seconds in an overload queue and 30 seconds executing. A different query has no queue time but generates millions more join rows than expected. Would the same adjustment solve both?
Check your reasoning
For the first query, inspect concurrent workloads and whether to isolate or scale them. For the second, inspect join keys, uniqueness and operator row counts. Use Query Profile or Query Insights for evidence. Query attribution associates eligible compute with statements, while warehouse metering also reflects idle time.
Compare the choices
- Overload queue time
- Distinguish time spent waiting for execution capacity from time spent in query operators.
- Spill metrics
- Inspect bytes spilled locally or remotely to identify operators under memory pressure.
- Partitions scanned
- Compare scanned partitions with total partitions and the selectivity of the filter.
- Join output cardinality
- Examine input and output row counts to find multiplication from duplicate keys or incomplete join conditions.
- Query attribution history
- Examine compute attributed to individual queries and separate this from total warehouse spend.
- Query Insights
- Use platform-generated observations about a statement as leads, then validate them against profile evidence.
Test the decision
Suppose 1,000 order lines join to a dimension with three rows per order key. The 3,000 output rows may overstate totals. Correct the data grain or join condition and rerun before increasing compute. Compare like-for-like query samples and retain the query IDs.
Practice the guide skills
- Use Query Profile to match the largest operator cost to the intended work. Watch 2:32:16
- Treat a Query Insight as a hypothesis and identify the profile evidence that would confirm it. Watch 2:32:40
- Locate local and remote spill bytes and compare input size across runs. Watch 2:32:49
- Compare partitions scanned with total partitions for a representative selective predicate. Watch 2:33:05
- Explain a join whose output greatly exceeds the expected input grain and check key uniqueness. Watch 2:33:57
- Separate time spent queued from execution time using query history. Watch 2:34:42
- Use query attribution to assign eligible compute to query IDs while keeping idle warehouse cost separate. Watch 2:35:46
- Group workloads by concurrency, latency target and owner before assigning warehouses. Watch 2:36:10
Official objectives for this lesson
Lab · Find which query lost time and why
Use synthetic query history and operator measurements. Calculate the queue share, partitions scanned and join expansion to choose a different next test for each query.
runs = [
("dashboard", 60, 15, 8, 200, 400, 400),
("date-filter", 0, 60, 180, 200, 320, 320),
("lookup-join", 1, 49, 15, 200, 300, 2400),
]
for name, queued, execution, scanned, total, expected, actual in runs:
queue_share = 100 * queued / (queued + execution)
scan_share = 100 * scanned / total
join_ratio = actual / expected
print(f"{name}: queue {queue_share:.0f}%, scan {scan_share:.0f}%, "
f"join {join_ratio:.1f}x")
Check the result
dashboard: queue 80%, scan 4%, join 1.0x date-filter: queue 0%, scan 90%, join 1.0x lookup-join: queue 2%, scan 8%, join 8.0x
Inspect concurrency for dashboard. Check predicate selectivity and clustering for date-filter. For lookup-join, verify key uniqueness before resizing compute. Change expected output to reflect a documented one-to-many relationship and rerun. High expansion only signals a defect when it conflicts with the intended grain.
Related lesson · Optimize the measured bottleneck
Use query evidence to explain a slowdown quiz
Answer 3 questions. Check each answer for an explanation.