What you will be able to do
- Open the query profile for a specific past query run from Query History, the SQL editor, a notebook or a system.query.history record
- Find the expensive step in a profile using Top operators, DAG metrics and verbose mode
- Match a performance insight such as spill, uneven data distribution or an exploding join to its recommended fix
- Tell a query that was slow to execute from one that waited in the warehouse queue
- Share a query profile by URL or as a JSON file, depending on the recipient's permissions
Key concept
Query profile — A query profile records how one specific query run actually executed: every operator with its measured time, rows and memory, plus the performance insights Databricks raised. You read it to find the step that cost the most, then fix that step instead of guessing.
1.Opening the profile of a past query run
Every query that runs on a SQL warehouse or serverless compute leaves a record, and the way into its execution details is Query History. Say a dashboard query that usually takes ten seconds took four minutes yesterday afternoon. Click Query History in the sidebar, narrow the list down, and click the query's name. The list can be filtered by user, date range, compute, duration, query status, statement type, statement ID and query tags, so finding yesterday's slow run is a matter of setting a date range and a duration filter. To spot the slowest queries across a whole warehouse instead of one known query, sort by duration in the UI or in the system table, as covered in Query history page and system.query.history.
Clicking the query opens a query details panel on the right. It shows the run's status (Queued, Running, Finished, Failed or Cancelled), the user and compute, a UUID for this execution, the full statement, popular metrics with filter icons showing what percentage of data was pruned during scanning, and the wall-clock duration. Below the duration there is a breakdown into scheduling, query optimization and file pruning, and execution time. The panel also holds a small preview of the execution graph and a See longest operators for this query button. Click See query profile to open the full profile.
The profile contains measurements from that particular execution: how long each operator ran, how many rows it handled, and how much memory it used. Other places in the workspace answer different questions. Catalog Explorer describes tables, and a warehouse's Monitoring tab shows load on the whole warehouse. Neither one breaks a single run down operator by operator.
To view a profile, you must own the query or have at least CAN MONITOR on the SQL warehouse that ran it. Without one of those, the query can still be in the list, but its profile will not open for you.
A cache hit is fast because nothing actually ran, and that is why it has nothing to profile. If you rerun a query to study it and get "Query profile is not available", force a real execution with a trivial edit, such as changing or removing the LIMIT.
Checkpoint 1 of 9· Put it in order
A dashboard query that usually takes ten seconds took four minutes yesterday afternoon. Put the steps to open that run's query profile in order.
- 1.Click Query History in the sidebar
- 2.Click See query profile to open the full profile
- 3.Filter the list by date range and duration to find yesterday's slow run
- 4.Click the query's name to open the query details panel on the right
Query History is the way into past runs. Filters narrow the list, clicking a query opens its details panel, and the full profile opens from that panel's See query profile button.
“Click the name of a query. A query details panel appears on the right side of the screen.”Source: docs.databricks.com
Checkpoint 2 of 9· Check yourself
An analyst can see a colleague's slow query in Query History, but its profile won't open for them. The analyst does not own the query. Which access would let them open the profile?
To view a profile you must own the query or have at least CAN MONITOR on the warehouse that ran it. Table privileges and the permission to run queries on the warehouse do not grant access to the profile.
“must either be the owner of the query or you must have at least CAN MONITOR permission on the SQL warehouse”Source: docs.databricks.com
Checkpoint 3 of 9· Exam question
A data analyst wants to investigate why a specific SQL query ran unusually slowly yesterday. Where in Databricks SQL should they go to open that query's detailed execution profile?
Correct answer: A — Open Query History, select the query by name or timestamp, then choose "See query profile" to view its execution DAG and metrics.
- A. Query History lists every executed query, and selecting a query and opening its query profile is the documented path to the per-operator execution DAG, timing, and I/O metrics used to diagnose poor performance. This is the correct starting point for investigating a specific past query.
- B. Query lineage in Catalog Explorer shows which queries and jobs read or wrote a table, not the execution timing or resource usage of a single run. It does not surface the DAG or task-level metrics needed to diagnose slowness.
- C. The warehouse monitoring page shows aggregate cluster utilization and concurrency across all queries on that warehouse, not the execution breakdown of one specific query. It cannot pinpoint which operator inside a single query caused the slowdown.
- D. Running
EXPLAINreturns the planned logical and physical execution steps before the query runs, not the actual runtime metrics, row counts, or spill/skew data from the completed execution. It is useful for plan inspection but not for profiling a query that already ran.
2.Finding the expensive step: top operators, the DAG and verbose mode
The detailed profile has summary tabs on the left and a graph on the right. The left tabs are Details (summary metrics), Top operators and Query text. Top operators is the fastest route to a diagnosis because it ranks the most expensive operators in the query. You can start from the costliest step instead of reading the plan from the top.
The right half is the directed acyclic graph (DAG) of operators. Each node can display Time spent, Memory peak or Rows. Click a metric to switch which one the graph reports. Each one points to a different kind of problem. Time spent shows where the clock went. Rows shows where row counts jump unexpectedly, such as a join that outputs far more rows than it took in. Memory peak shows operators under memory pressure. You can search the graph to highlight operators or columns, zoom in on part of it, and click any operator to open a panel with its detailed metrics. Some non-Photon operations run as a group and share metrics, so they all show their parent operator's value for a given metric. For Databricks SQL queries, the kebab menu also offers Open in Spark UI.
By default the graph hides metrics for some operations, because those operations are unlikely to cause bottlenecks. When the visible operators don't explain the runtime, use the menu at the top of the page and choose Enable verbose mode. It shows every operation and adds extra metrics.
| Operator | What happened | What to watch for |
|---|---|---|
| Scan | Data was read from a data source and output as rows | Full table scans; check the pruning shown in the query metrics |
| Filter | Input was reduced by a criterion such as a WHERE clause | A filter that runs late, after expensive work has already happened |
| Join | Rows from multiple relations were combined into one set | Output rows far above input rows (an exploding join) |
| Union | Rows from relations with the same schema were concatenated | Large inputs that are combined and then mostly discarded |
| Shuffle | Data was redistributed or repartitioned | Expensive, because data moves between executors on the cluster |
| Hash / Sort | Rows were grouped by key and aggregated with SUM, COUNT or MAX | High memory peak on large groupings |
Checkpoint 4 of 9· Check yourself
In a query profile, the operators visible in the DAG add up to only a fraction of the query's four-minute runtime. What should the analyst do next to find the missing cost?
By default the profile hides metrics for operations that are unlikely to be bottlenecks. Verbose mode shows every operation and adds extra metrics. Switching metrics or reading the query text still leaves those hidden operations out, and an unchanged rerun may come from the cache and produce no profile at all.
“To see information for all operations, and to see additional metrics, click at the top of the page, then click Enable verbose mode.”Source: docs.databricks.com
Sources1
3.Performance insights: Databricks names the likely problem
Operator metrics show you where time went. Performance insights go a step further and say what is probably wrong. When a query runs, Databricks can return insights that flag a likely cause, and each comes with a recommendation. They appear in two places. The query details panel shows a summary of the most impactful insights, ranked by their estimated effect on total task duration. The Performance insights tab in the full profile shows each insight in detail. Some insights don't flag a problem. They are labelled Accelerated and report optimizations Databricks already applied, such as reading less data thanks to Automatic Liquid Clustering, or choosing a broadcast join based on previous runs. They need no action.
For insights you can act on, Optimize opens Genie Code. If the fix is a query change, Genie Code rewrites the query and presents the changes for your approval. If the fix involves the table or compute, it summarizes the recommended actions in plain language.
| What the insight reports | Recommended action |
|---|---|
| Data spilled to disk because it did not fit in memory | Increase the warehouse size to add memory; reduce the rows, columns or size of large columns |
| Data is distributed unevenly across computing resources | Review the data distribution, then use key salting or pre-aggregation |
| The join produces significantly more rows than it reads | Change the join condition or reduce input rows on both sides |
| The join produces significantly fewer rows than it reads | Add filters before the join to reduce input rows |
| The table is clustered or partitioned by keys not used in filters | Add filters on the clustering or partitioning keys |
| The query projects all columns from the table | Project only the columns you need |
| The table scan reads many small files | Enable Predictive Optimization or run OPTIMIZE; switch partitioned tables to liquid clustering |
| Cost-based optimizer statistics are missing or incomplete | Collect statistics so the optimizer can produce a better plan |
| Photon can't accelerate this operation | Review Photon limitations and use a supported execution path |
| The query waited in the warehouse queue | Increase the maximum number of clusters on the warehouse |
| A cloud storage request was throttled by the cloud provider | Ask your administrator to request higher storage request limits from the cloud provider |
Spill is the classic sign of memory pressure. Picture a GROUP BY over billions of rows that finishes but runs far too long. In its profile, the aggregation operator's memory peak is above what the warehouse has available, and data was spilled to disk. Each insight in the table has its own signature, and spill's signature is memory. That means the fix is either more memory (a larger warehouse) or less data reaching the operator (fewer rows, fewer columns, smaller wide columns). Throttling, queueing and table layout each produce their own, different insight.
Skew looks different. The stage's total work may be reasonable, but one or a few tasks take much longer than the rest. In a join or aggregation, the usual cause is that a few key values hold most of the data. The task that gets those keys becomes the straggler that everything else waits for. The matching insight reports data distributed unevenly across computing resources. The fix targets that distribution: check how the join key's values are spread, then salt the hot keys or pre-aggregate. A larger warehouse doesn't help much, because the one overloaded task is still doing most of the work. Collecting statistics and avoiding Photon limitations are fixes for other insights, not this one.
Checkpoint 5 of 9· Match them up
Match each performance insight to the action Databricks recommends for it.
Tap a term, then the definition that fits it.
Each insight points to a different cause, so each has its own fix. Spill is memory pressure, so the fix is more memory or less data. Skew is uneven distribution, which salting or pre-aggregation addresses and a bigger warehouse barely helps. Queue wait is a capacity problem solved by more clusters. Throttling is a cloud provider limit that only an administrator can get raised.
“Recommendation: Review the data distribution, then use key salting or pre-aggregation to balance the workload.”Source: docs.databricks.com
Checkpoint 6 of 9· Exam question
A GROUP BY query aggregating billions of rows completes successfully but takes far longer than expected. In the query profile, the aggregation operator shows a large "bytes spilled to disk" value and a peak memory figure well above the warehouse's available memory. What does this indicate, and what should the analyst try first?
Correct answer: A — The operator ran out of memory and spilled data to disk, so the analyst should increase the warehouse size or filter earlier to shrink the aggregated data volume.
- A. A large spill value paired with peak memory above the available limit is the classic signature of an out-of-memory aggregation writing intermediate state to disk. Sizing up the warehouse or shrinking the data being aggregated directly reduces the memory pressure causing the spill.
- B. Storage throttling shows up as I/O wait time on scan operators, not as a spill metric on an aggregation operator. This distractor misreads a memory-pressure symptom as a network problem, so it would not address the actual cause.
- C. Clustering improves file pruning during scans, but a spill on an in-memory aggregation operator is a memory sizing issue, not a data layout issue. Reclustering the table would not reduce the memory an already-scanned aggregation needs to hold.
- D. Queueing from concurrency contention delays when a query starts running, but the profile here shows an operator that is executing and spilling, meaning it already has compute. Adding clusters for concurrency would not shrink this operator's own memory footprint.
Checkpoint 7 of 9· Exam question
A join between a large fact table and a small dimension table finishes, but the query profile shows one task in the shuffle stage processing far more rows and taking dramatically longer than the other tasks in that same stage. What problem does this pattern point to, and what should the analyst investigate?
Correct answer: A — This pattern indicates data skew, where one key value has far more matches than others, so the analyst should check the join key's distribution and salt or filter the skewed value.
- A. One task handling far more rows and time than its peers in the same shuffle stage is the textbook signature of data skew: a small number of key values dominate the partition that task is assigned. Investigating the key distribution and salting or isolating the hot value is the standard remediation.
- B. An undersized warehouse would slow every task roughly proportionally to the data it holds, not create one dramatically slower task while its peers finish quickly. Resizing without addressing the skewed key would leave the imbalance between tasks unchanged.
- C. Missing statistics can affect the optimizer's choice between broadcast and shuffle joins, but it does not explain why one specific task within an already-chosen shuffle stage is overloaded. The uneven task, not the join strategy, is the symptom described here.
- D. Photon acceleration affects per-task execution speed but does not explain why the shuffle assigns disproportionate rows to a single task. Rewriting the join as unioned subqueries would not fix an underlying skewed key and adds unnecessary complexity.
4.Telling a slow query from a queued one
A long wall-clock time doesn't always mean the SQL is slow. A query can spend most of its duration waiting for the warehouse before its first operator runs. The details panel breaks the duration into scheduling, optimization and file pruning, and execution. If scheduling dominates, the profile has little to tune. In system tables the split is explicit: waiting_at_capacity_duration_ms counts time spent queued for capacity, waiting_for_compute_duration_ms counts time waiting for compute to be provisioned, compilation_duration_ms covers metadata loading and optimization, and execution_duration_ms is the time actually spent running. How a warehouse admits, queues and scales queries is explained in Warehouse admission, queuing and scaling.
Before you tune the SQL, check the warehouse load. On the warehouse's Monitoring tab, live statistics show the number of running queries, the number of queued queries and the current cluster count. You can hover over a duration in its query table to see it split into scheduling and running time. These views describe the warehouse as a whole, not the operators inside one query, so they tell you whether to look at capacity or at the query. To find queued queries across a week, query the system table directly:
SELECT
statement_id,
executed_by,
total_duration_ms,
waiting_at_capacity_duration_ms,
execution_duration_ms,
start_time,
statement_text
FROM
system.query.history
WHERE
compute.warehouse_id = '<warehouse-id>'
AND start_time >= NOW() - INTERVAL 7 DAY
AND waiting_at_capacity_duration_ms > 0
ORDER BY
waiting_at_capacity_duration_ms DESC
LIMIT 50High queue time is a capacity problem, and the fix is to raise the warehouse's max_clusters so it can scale out. High execution time with little queueing points back to the profile and its insights. The same table also surfaces memory problems at scale: filter on spilled_local_bytes > 0 to list queries that spilled. Both cases are sizing signals, but for different resources. Queueing calls for more clusters, and spill calls for a larger cluster size.
Aggregated task time (total_task_duration_ms in the system table) is the combined time across all cores of all nodes. Being larger than wall-clock time is normal and shows parallelism at work. Task time *shorter* than wall-clock time is the case to look at: it can mean tasks waited for available nodes.
Checkpoint 8 of 9· Fill the gap
An analyst suspects that a warehouse's slow dashboards were waiting for capacity, not running slow SQL. Which column completes the filter so that only queries that sat in the queue are listed?
SELECT
statement_id,
executed_by,
total_duration_ms,
waiting_at_capacity_duration_ms,
execution_duration_ms,
start_time,
statement_text
FROM
system.query.history
WHERE
compute.warehouse_id = '<warehouse-id>'
AND start_time >= NOW() - INTERVAL 7 DAY
AND ? > 0
ORDER BY
waiting_at_capacity_duration_ms DESC
LIMIT 50waiting_at_capacity_duration_ms counts the time a query spent queued for available warehouse capacity. A high value means raising max_clusters, not rewriting the SQL. waiting_for_compute_duration_ms measures time waiting for compute to be provisioned, and execution_duration_ms and total_duration_ms don't separate out the queue time.
Source: docs.databricks.com5.Sharing a profile and reaching it from other tools
Diagnosing a slow query often means showing it to someone else, and there are two ways to share a profile. If the colleague has CAN MANAGE on the query, open the query from Query History and click Share, which copies the profile URL to your clipboard. If they lack that permission or aren't in the workspace, click Download to save the profile as a JSON file. The recipient imports it from Query History's kebab menu with Import query profile (JSON). An imported profile loads into their browser session only and doesn't persist in the workspace, so they have to import it again each time they want to view it.
Query History isn't the only way to open a profile. You can also reach one from:
- The SQL editor, through the elapsed-time and row-count link below the results, which opens the query details panel
- A notebook attached to a SQL warehouse or serverless compute, through See performance under the cell
- The Query History tab of the Lakeflow pipelines UI, and the jobs UI for jobs run on SQL warehouses or serverless compute
- A
system.query.historyrecord: copy itsstatement_id, make sure you are in the workspace named byworkspace_id, paste the ID into the Statement ID filter in Query History, and click See query profile
The last route turns a large-scale search, such as "every query that spilled this week", into an operator-level diagnosis of each one.
Download the profile as JSON and send the file. A Share URL needs CAN MANAGE on the query and workspace membership. The contractor imports the JSON into their own Query History view, but it lives only in that browser session and must be re-imported to view it again.
Checkpoint 9 of 9· Put it in order
A weekly query on system.query.history with spilled_local_bytes > 0 flags one statement as the worst spiller. To diagnose it operator by operator, arrange the steps that take you from that record to its query profile.
- 1.Copy the record's statement_id from the system table result
- 2.Check the record's workspace_id and make sure you are logged in to that workspace
- 3.Click the query's name, then click See query profile
- 4.Click Query History in the sidebar and paste the statement_id into the Statement ID filter
The statement_id identifies that exact execution. Query History only lists runs from the workspace you are logged in to, so you first confirm you are in the workspace named by workspace_id. Then you filter on the statement ID and open the profile from the query details panel.
“Reference the record's workspace_id to ensure you are logged in to the same workspace as the record.”Source: docs.databricks.com
Practise it for real
Go from a warehouse-wide search for spilling queries to the operator-level diagnosis of one of them.
1.In the SQL editor, query system.query.history for the last 7 days with spilled_local_bytes > 0, ordered by spilled_local_bytes DESC, filtered to your warehouse's compute.warehouse_id.
Why: The system table finds candidate queries at scale. By default only admins can read it, so ask an admin for access or a dynamic view if you need one.
You should see: A list of statement_id values with spilled bytes, read bytes, duration and statement text.
2.Copy the statement_id of the worst offender, open Query History, and paste it into the Statement ID filter.
Why: The statement_id identifies that exact execution in the Query History UI.
You should see: One matching query run in the list.
3.Click the query, then See query profile, and open the Top operators tab.
Why: Top operators ranks the most expensive steps, so you start at the costliest operator.
You should see: An aggregation, join or sort near the top, with a high Memory peak.
4.Open the Performance insights tab.
Why: The insight confirms the diagnosis and gives the recommended action.
You should see: A spill insight recommending a larger warehouse or fewer rows, columns or large-column bytes.
Stuck? Get a nudge
If the profile shows as unavailable, the run you picked was served from cache. Choose a different statement_id where from_result_cache is false.
Sources
(7)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Click See query profile to open the detailed DAG.”
↩︎ Opening the profile of a past query run“you must have at least CAN MONITOR permission on the SQL warehouse that executed the query”
↩︎ Opening the profile of a past query run“A detailed breakdown of scheduling, query optimization and file pruning, and execution time appears below the summary.”
↩︎ Opening the profile of a past query run“A query profile is not available for queries that run from the query cache.”
↩︎ Opening the profile of a past query run“Top operators: Opens the Top operators panel which shows the most expensive operators used in your query.”
↩︎ Finding the expensive step: top operators, the DAG and verbose mode“The graph view shows metrics such as Time spent, Memory peak, and Rows.”
↩︎ Finding the expensive step: top operators, the DAG and verbose mode“These operations are unlikely to be the cause of performance bottlenecks.”
↩︎ Finding the expensive step: top operators, the DAG and verbose mode“Shuffle operations are expensive with regard to resources because they move data between executors on the cluster.”
↩︎ Finding the expensive step: top operators, the DAG and verbose mode“For Databricks SQL queries, you can also view the query profile in the Spark UI.”
↩︎ Finding the expensive step: top operators, the DAG and verbose mode“For an insight that requires a query change, Genie Code rewrites the query and presents the changes for your approval.”
↩︎ Performance insights: Databricks names the likely problem“If the other user has the CAN MANAGE permission on the query, you can share the URL for the query profile with them.”
↩︎ Sharing a profile and reaching it from other tools“When you import a query profile, it is dynamically loaded into your browser session and does not persist in your workspace.”
↩︎ Sharing a profile and reaching it from other tools“The query profile helps you troubleshoot performance bottlenecks during the query's execution.”
↩︎ Key concept“To circumvent the query cache, make a trivial change to the query, such as changing or removing the LIMIT.”
↩︎ Exam trap 1“If the other user has the CAN MANAGE permission on the query, you can share the URL for the query profile with them.”
↩︎ Exam trap 5“Click the name of a query. A query details panel appears on the right side of the screen.”
↩︎ Checkpoint“must either be the owner of the query or you must have at least CAN MONITOR permission on the SQL warehouse”
↩︎ Checkpoint“To see information for all operations, and to see additional metrics, click at the top of the page, then click Enable verbose mode.”
↩︎ Checkpoint - 2.
“filter the list by user, date range, compute, duration, query status, statement type, statement ID, and query tags”
↩︎ Opening the profile of a past query run - 3.
“The query details panel shows a summary of insights, ranked by their estimated effect on total task duration.”
↩︎ Performance insights: Databricks names the likely problem“Data spilled to disk during query execution because the data did not fit in memory.”
↩︎ Performance insights: Databricks names the likely problem“Increase the warehouse size to add memory.”
↩︎ Performance insights: Databricks names the likely problem“Review the data distribution, then use key salting or pre-aggregation to balance the workload.”
↩︎ Performance insights: Databricks names the likely problem“The join produces significantly more rows than it reads.”
↩︎ Performance insights: Databricks names the likely problem“Cost-based optimizer statistics are missing or incomplete, so the query plan uses standard heuristics.”
↩︎ Performance insights: Databricks names the likely problem“Photon can't accelerate this operation, so the query uses the standard runtime engine.”
↩︎ Performance insights: Databricks names the likely problem“A cloud storage request was throttled by the cloud provider.”
↩︎ Performance insights: Databricks names the likely problem“They appear in the Performance insights tab with an Accelerated label and do not require action.”
↩︎ Performance insights: Databricks names the likely problem“They appear in the Performance insights tab with an Accelerated label and do not require action.”
↩︎ Exam trap 2“Review the data distribution, then use key salting or pre-aggregation to balance the workload.”
↩︎ Exam trap 3“Recommendation: Review the data distribution, then use key salting or pre-aggregation to balance the workload.”
↩︎ Checkpoint - 4.
“Skew happens when one or a few tasks take much longer than the rest.”
↩︎ Performance insights: Databricks names the likely problem“If a few key values hold most of the data in a join or aggregation”
↩︎ Performance insights: Databricks names the likely problem - 5.
“Time spent waiting in queue for available compute capacity in milliseconds.”
↩︎ Telling a slow query from a queued one“It can be significantly longer than the wall-clock duration if multiple tasks are executed in parallel.”
↩︎ Telling a slow query from a queued one“In the Statement ID field, paste the statement_id on the record.”
↩︎ Sharing a profile and reaching it from other tools“Reference the record's workspace_id to ensure you are logged in to the same workspace as the record.”
↩︎ Checkpoint - 6.
“Queries with high waiting_at_capacity_duration_ms values are spending time queued instead of running.”
↩︎ Telling a slow query from a queued one“Queries with high waiting_at_capacity_duration_ms values are spending time queued instead of running.”
↩︎ Exam trap 4 - 7.
“the number of running queries, the number of queued queries, and the warehouse's current cluster count”
↩︎ Telling a slow query from a queued one