Summary of "How I Made a 21-Second Query Run in 0.07 Seconds"

Summary of the video (SQL performance optimization: 21s → 0.07s)

Step-by-step process used

  1. Measure where the time goes (SSMS profiling approach)

    • The report relied on SQL Server stored procedures.
    • The author ran the same stored procedure calls in a new query editor, adding PRINT statements with timestamps between procedure calls.
    • They checked actual timings via SSMS “Messages” tab output.
  2. Narrow to the worst stored procedure

    • One stored procedure accounted for ~half of the report’s total elapsed time (about 30 seconds).
  3. Instrument inside that stored procedure

    • The author converted the stored procedure into a script form (not actually creating/calling it) to insert additional PRINT statements.
    • Inside it, one particular internal query consumed ~21 of the 30 seconds.
  4. Use the Actual Execution Plan (not estimated)

    • The author enabled the Actual Execution Plan and observed runtime slightly above 21 seconds.
    • Key execution-plan observations:
      • There were index seeks on the large transactions table (a good sign, but not sufficient).
      • A sort step was the most expensive operation.
      • The most important clue was row-count flow:
        • Millions of rows entered early stages (joins / cross apply / grouping),
        • then the rowset was reduced to only ~500 rows late by a filter.
      • Net effect: processing millions to return 500.

What caused the slowdown

The fix

Why the execution plan improved

Generalizable principles / guidance

Resources mentioned

Main speakers / sources

Category ?

Technology


Share this summary


Is the summary off?

If you think the summary is inaccurate, you can reprocess it with the latest model.

Video