Query Performance & Optimization
Understand where a query spends its time. Follow one orders workload from a correct result to an execution plan, a testable hypothesis and a measured engineering decision.
Before you begin
14 focused lessons · About 405 minutes of guided study and practice. Learning estimates include reading and investigation; actual account experiments vary.
Know warehouse basics, joins and windows, dynamic tables and clone isolation. Lesson 1 creates six orders and three customers in a fresh L2_OBJECTS_LAB.M15_LAB schema.
Use an authorized role and warehouse. The core SQL path does not require Enterprise features. Optional Search Optimization, Materialized Views, Query Acceleration and multi-cluster exercises need Enterprise or higher plus the listed privileges. Background services and larger datasets can consume additional credits and storage.
The website does not run SQL. Result rows are derived from the supplied data; timings and scan statistics must come from your account. A six-row query is for understanding correctness, not for proving a speedup.
Begin Module 15 →Your investigation path
Understand execution
Separate compilation, queues and operators. Learn how column data and partition metadata affect scans.
Find the expensive work
Read Query Profile. Identify row growth, poor pruning, wide intermediate data and memory pressure.
Choose a justified change
Compare SQL, storage services and warehouse decisions against the workload’s requirements.
Prove the outcome
Validate exact results, record query IDs and compare repeat runs under similar conditions.
Complete curriculum scope
- Micro-partition internals: min/max metadata, partition pruning, and pruning efficiency.
- Natural clustering, clustering depth/overlap, key selection, multi-column/expression keys, and SYSTEM$CLUSTERING_INFORMATION.
- Automatic Clustering, reclustering behavior, and poor-pruning diagnosis.
- Query Profile: execution tree, scan/join/aggregation operators, compilation, execution, network transfer, and local/remote spill.
- Query tuning: join explosion, Cartesian joins, predicate pushdown, column pruning, join ordering, windows, and CTEs.
- Caching: persisted query results/result reuse, warehouse/local cache, metadata cache, invalidation, and suspend effects.
- Search Optimization Service: point lookups, text, VARIANT, and geospatial workloads.
- Materialized Views: use cases, maintenance, limitations, and comparison with standard views.
- Query Acceleration Service: eligibility and scale factor; Snowflake Optima overview.
- Workload analysis using query history and Performance Explorer; sizing/concurrency decisions using Module 02.
- Lab: Diagnose a slow query and choose a performance strategy from measured evidence.
Your lesson path
- Lesson 1 · About 25 min
How Snowflake executes a query
Create a shared orders dataset and distinguish compilation, queueing, scanning, joins, aggregation and result delivery before tuning SQL.
Read, visualize and investigate → - Lesson 2 · About 25 min
Micro-partition pruning and selective filters
Use min/max ranges and Query Profile to distinguish eligible partitions, matching rows and the benefit of selective business filters.
Read, visualize and investigate → - Lesson 3 · About 25 min
Natural clustering, overlap and depth
Compare well-grouped and overlapping date ranges, inspect clustering information and distinguish natural load order from a maintained clustering key.
Read, visualize and investigate → - Lesson 4 · About 25 min
Choose clustering keys and evaluate maintenance
Choose clustering keys from workload evidence, inspect background maintenance and weigh selective query gains against service and retained-storage costs.
Read, visualize and investigate → - Lesson 5 · About 25 min
Read Query Profile from the expensive operator outward
Inspect scans, joins, filters, aggregates and sorts using operator rows, bytes, elapsed-time categories and query history.
Read, visualize and investigate → - Lesson 6 · About 25 min
Join explosion: fix the result before the runtime
Predict join output, diagnose missing predicates and duplicate dimension keys, and preserve the intended business grain.
Read, visualize and investigate → - Lesson 7 · About 25 min
Reduce unnecessary work: filters, columns, windows and CTEs
Review predicate placement, projection, window partitions and CTE usage without assuming a particular SQL rewrite always runs faster.
Read, visualize and investigate → - Lesson 8 · About 25 min
Memory pressure, spilling and redistribution
Connect wide joins, large sorts and skew to memory pressure, then choose between reducing work and increasing resources.
Read, visualize and investigate → - Lesson 9 · About 25 min
Result reuse, warehouse cache and metadata
Run a controlled cache comparison and explain reuse conditions, invalidation, expiration and suspension behavior.
Read, visualize and investigate → - Lesson 10 · About 30 min
Search Optimization for selective lookups
Match equality, text, VARIANT and GEOGRAPHY predicates to the appropriate search method and evaluate maintenance before enabling a paid service.
Read, visualize and investigate → - Lesson 11 · About 30 min
Materialized Views and choosing a maintained result
Compare standard views, materialized views and dynamic tables using freshness, query restrictions, maintenance and workload reuse.
Read, visualize and investigate → - Lesson 12 · About 30 min
Query Acceleration and Snowflake Optima
Investigate QAS eligibility, interpret scale factor as a resource limit and recognize current Optima behavior without promising automatic speedups.
Read, visualize and investigate → - Lesson 13 · About 30 min
Sizing, concurrency and workload investigation
Use timing phases and workload history to choose SQL optimization, scale-up, scale-out or workload isolation.
Read, visualize and investigate → - Lesson 14 · About 60 min
Final lab: investigate a slow regional revenue report
Investigate January paid revenue, compare equivalent SQL, preserve query evidence and recommend an optimization only when measurements justify it.
Read, visualize and investigate →
Your final performance investigation
Investigate January paid revenue. Save baseline and candidate query IDs, inspect actual operators, compare results in both directions and write a recommendation supported by your observations. Identical plans or no measurable improvement are valid findings.
Open the final investigation lab →Module 16 — Cost Management & Optimization remains planned. Track 4 is not yet complete.
Return to curriculum →