Skip to content

Diagnosing a slow query from its telemetry down to the root cause

Troubleshooting slow queries in Snowflake starts with Query Profile, which visualizes execution steps and highlights the most time- and resource-consuming operators. Combine this with warehouse sizing, spillage, and pruning metrics to isolate whether the bottleneck is compute, data volume, or query design. History views (QUERY_HISTORY, ACCESS_HISTORY) and system functions help correlate performance issues with warehouse load and concurrency.

1 · Learn the must-know

  • Query Profile shows execution time per node, bytes scanned, partitions scanned vs. total, and row counts, making it the first stop for diagnosing slow queries.
  • High 'bytes spilled to local/remote storage' in Query Profile indicates the warehouse is undersized for the operation (e.g., large sorts/joins), so resizing (scaling up) or optimizing the query can help.
  • Poor partition pruning (scanned partitions close to total partitions) signals ineffective clustering or filter predicates that don't align with the table's natural or defined clustering key.
  • Queuing time (visible in QUERY_HISTORY as QUEUED_PROVISIONING_TIME or QUEUED_OVERLOAD_TIME) reflects warehouse contention/concurrency issues, not query inefficiency, and may require a larger warehouse or separate warehouse for the workload.
  • Exploding joins (cartesian products) or repeated small operations show up in Query Profile as operators with row counts far exceeding input row counts, a common root cause of runaway query times.
  • The RESULT_SCAN and caching behavior mean re-running an identical query may appear fast due to result cache, so always check 'Persisted Query Results' reuse before concluding a query was optimized.

2 · Check your understanding

Check this objectiveFree · always available

A Data Engineer investigates a nightly aggregation query that takes over 40 minutes to complete on an X-Small virtual warehouse dedicated to this job. The Query Profile shows the GroupingAggregate operator reporting 18 GB of 'Bytes spilled to local storage' and 4 GB of 'Bytes spilled to remote storage'. The warehouse has MAX_CLUSTER_COUNT set to 1, and no other query runs concurrently on it. The pipeline SLA requires the job to finish in under 15 minutes without changing the SQL logic. What should the Engineer do to resolve the bottleneck?

Your objective map0 tried · 0 answered correctly · 22 untouched

What you have tried across SnowPro Advanced Data Engineer's objectives, not a readiness score.

Data Movement28% of the exam*0 of 7 tried
Performance Optimization19% of the exam*0 of 3 tried
Storage and Data Protection14% of the exam*0 of 3 tried
Data Governance14% of the exam*0 of 2 tried
Data Transformation25% of the exam*0 of 7 tried

* Our estimate. Snowflake publishes no section weights.

3 · Keep going