Execution Plan Interpretation

Reading operators, properties, plan shape, and actual-versus-estimated behavior.

92 associated posts86 primary posts

You Can’t Trust “Edit Query Text” in SSMS’s Execution Plans.

When there are IF branches or conditional logic, "Edit Query Text" only shows you the branches that actually executed. It's easy to miss whole swaths of code that didn't happen to execute one particular time.

To demo it, let's create a simple stored procedure with an IF branch that sometimes executes, and sometimes doesn't:

Read more about You Can’t Trust “Edit Query Text” in SSMS’s Execution Plans. Be the first to comment
Performance Tuning

Query Plan Pop Quiz Answers 2 and 3: I’ve Got Good News and Bad News.

In the Query Plan Pop Quiz, questions 2 and 3 asked you about what the sizes of arrows on query plans meant. The good news is that almost all of you got Question 2 right, but the bad news is that the vast majority of you got Question 3 completely incorrect, and the saddest part of that is that you've been using that inaccurate knowledge to guide your query tuning - and wasting your time.

Read more about Query Plan Pop Quiz Answers 2 and 3: I’ve Got Good News and Bad News. 5 comments — Join the discussion
Performance Tuning

Query Plans Pop Quiz Answer #1: Costs are Garbage.

In last week's Query Plans Pop Quiz, the first question was, someone hands you these two queries and you get their estimated plans to decide which query to tune. Perhaps you get the estimated plans from SSMS, or from sp_BlitzCache, or from your monitoring tool. The question was, which query should you focus on tuning?…

Read more about Query Plans Pop Quiz Answer #1: Costs are Garbage. 4 comments — Join the discussion
Performance Tuning

Query Plans Pop Quiz: Three Simple Questions

Question 1: Pick the Problematic Plan: someone hands you a pair of queries, and you get the estimated query plans. (Perhaps you get the estimated plans from SSMS, or from sp_BlitzCache, or from your monitoring tool.) Which one of these two should you focus on tuning first, Query 1 or Query 2?

Question 2: on an estimated plan, what does the thickness of the colored arrow represent?

Read more about Query Plans Pop Quiz: Three Simple Questions 28 comments — Join the discussion

[Video] Office Hours at Breiðamerkursandur, Diamond Beach

Post your Azure SQL DB and SQL Server questions at https://pollgab.com/room/brento and upvote the ones you'd like to see me discuss. In this episode, I'm overlooking Breiðamerkursandur, Diamond Beach, one of the most Instagrammed places in Iceland. Here's a shot from a prior trip when I climbed up on one of the icebergs:

Read more about [Video] Office Hours at Breiðamerkursandur, Diamond Beach 1 comment — Join the discussion
Production DBA

Office Hours: Short Text Answers Edition

Not all of the questions y'all post at https://pollgab.com/room/brento require long-winded responses.

Brandon: Do you seen a rise in json queries to address impedance mismatch between data/objects? I struggled with EF to produce a query that was neither simple nor complicated against a properly designed db (according to 2 experts). Dropped EF; used json query in stored proc; it was magic.

Read more about Office Hours: Short Text Answers Edition 1 comment — Join the discussion
Performance Tuning

Estimated and Actual Plans Can Have Different Shapes.

A reader posted a question for Office Hours: Hi Brent, What is your take on Hugo Kornelis's explanation of execution plan naming. As her his explanation, estimated exec plan is simply an execution plan whereas actual execution plan = execution plan+run-time stats. Do you agree that the naming is flawed and confusing? - Yourbiggestfan I…

Read more about Estimated and Actual Plans Can Have Different Shapes. 17 comments — Join the discussion
Performance Tuning

SQL Server 2022 Tells You Why A Query Can’t Go Parallel.

Until 2022, when a query couldn't go parallel, all we got was a really cryptic note in the execution plan properties saying NonParallelPlanReason = CouldNotGenerateValidParallelPlan.

But starting with SQL Server 2022, even when I'm running under older compatibility levels:
[crayon-6a6ecdefdc66a733788308/]
The execution plan gives me way more details:

Read more about SQL Server 2022 Tells You Why A Query Can’t Go Parallel. 10 comments — Join the discussion