Let’s Get Certified
Module 07 / 13 · Analyze queries

Identify the expensive operator before tuning

Separate compute wait, scan volume, join expansion and data-version changes.

Identify the expensive operator before tuning

Work through the decision

A report took 90 seconds yesterday and 10 seconds today. The team credits Photon. Yesterday’s warehouse was stopped, today’s result came from cache, and the underlying Delta table changed overnight. What would be a fair comparison?

Check your reasoning

Hold the query, input version, compute configuration and cache conditions constant. Separate provisioning or queue time from execution in query history. Inspect the profile for scan bytes, pruning, join output and spill. A new execution engine can only accelerate work that actually ran on it.

Watch the source lesson at 1:21:49

Compare the choices

Photon
Use eligible vectorized native execution for supported SQL operators. Inspect operator eligibility and compare like-for-like runs.
Query profile
Inspect the operator graph and runtime metrics such as rows, bytes, pruning and spill. Identify the dominant operation.
Delta table history
Inspect commit metadata, versions, operation types and times. Use retained snapshots to validate when a result changed.
Query history
Locate past statements and their parameters, execution status and available timing details. Separate queue and run effects.

Test the decision

Use DESCRIBE HISTORY to identify commits, then compare the same reconciled measure at the relevant retained versions. A faster wrong result still requires a correctness investigation. A change to a table’s contents is different evidence from a change in the physical plan.

Compare a known table version

Run DESCRIBE HISTORY on the approved table and record its versions and operations. Re-run a fixed query for the relevant retained snapshots. Align filters, joins and time zones across runs. A recorded history entry can remain visible after old data files needed to query that snapshot are gone.

Databricks · Table history and time travel

Hold the aggregation constant across versions

DESCRIBE HISTORY ticketing.gold.sales;

SELECT 'before' AS snapshot, COUNT(*) AS sales, SUM(net_cents) AS net_cents
FROM ticketing.gold.sales VERSION AS OF 18
UNION ALL
SELECT 'after', COUNT(*), SUM(net_cents)
FROM ticketing.gold.sales VERSION AS OF 19
Check the result

Substitute retained versions from your own table history. Equal counts with different net cents justify comparing changed sale IDs and adjustment values. If an input file for an older version has expired, select a supported backup or retained snapshot.

Practice the guide skills

  1. Estimate whether Photon can help a SQL workload. Watch 1:21:49
    Check your answer

    Identify supported scans, joins and aggregations in the plan. Photon uses vectorized native execution for eligible operators. Compare the same input and compatible compute and inspect any fallback.

  2. A dashboard query is slow after its warehouse starts. Locate the bottleneck. Watch 1:23:23 · Continue at 1:23:45
    Check your answer

    Separate waiting and execution using query history. In the query profile compare scan bytes, pruning, join cardinality, shuffle and spill. Prioritize the operator accounting for the observed cost.

  3. Determine whether a change in a report reflects a data update. Watch 1:27:04 · Continue at 1:27:27
    Check your answer

    Inspect Delta history for the write operation and versions. Run the same query against both retained snapshots with the same parameters and compare the affected keys.

Official objectives for this lesson

Related lesson · Troubleshooting and optimization

Knowledge check

Identify the expensive operator before tuning quiz

Answer 3 questions. Check each answer for an explanation.

Worked example · Identify the expensive operator before tuning