Category: Execution Plans

Anatomy Of An Adaptive Join

I don't like it unless it's brand new
When new features drop, not everyone has time to jump on top of them and start looking at stuff. That's what consultants with nothing better to do are for.

I've been excited about this feature since talking to The Honorable Joseph Q. Sack, Esq. about it at PASS last October. My pupils dilated like I just found the bottom of a bottle of Laphroaig 18.

Read more about Anatomy Of An Adaptive Join 4 comments — Join the discussion
Performance Tuning

Using Trace Flag 2453 to Improve Table Variable Performance

I recently saw a server with trace flag 2453 configured. I hadn't come across this trace flag before, so I did a little research. Microsoft says it allows "a table variable to trigger recompile when enough number of rows are changed". This can lead to a more efficient execution plan. Trace flag 2453 is available in SP2 or greater for SQL Server 2012, CU3 or greater for SQL Server 2014 and RTM or greater for SQL Server 2016.

Read more about Using Trace Flag 2453 to Improve Table Variable Performance 18 comments — Join the discussion
Performance Tuning

Indexing Temp Tables

People often don't give this thought
Which is a shame, because I see people sticking fairly large amount of data into temp tables. On the rare occurrence that I do see them indexed, it's a nonclustered index on a column or two. The optimzer promptly ignores this index while you select 10 columns and join 10,000 rows to another temp table with another ignored nonclustered index on it.

Read more about Indexing Temp Tables 46 comments — Join the discussion
Performance Tuning

What’s the Difference Between Estimated and Actual Execution Plans?

I'm going to use the dbo.Users table in the StackOverflow demo database and run a pretty simple query: [crayon-6a6cf2de1da30308277609/] First, hit Control-L in SSMS and get the estimated execution plan. Here it is: Click on the plan, and hover your mouse over the various operators. You'll notice that almost all of the fields are prefixed…

Read more about What’s the Difference Between Estimated and Actual Execution Plans? 2 comments — Join the discussion
Performance Tuning

Using Plan Guides to Remove OPTIMIZE FOR UNKNOWN Hints

Say you've got an application that has tons of OPTIMIZE FOR UNKNOWN hints in the T-SQL, and you're getting bad query plans.

We're going to use the same StackOverflow query (and the same index on Reputation) that I demoed in the post Why Is This Query Sometimes Fast and Sometimes Slow? This technique produces a query that will produce two different execution plans depending on the Reputation parameter.

Read more about Using Plan Guides to Remove OPTIMIZE FOR UNKNOWN Hints 7 comments — Join the discussion
Performance Tuning

Why Is This Query Sometimes Fast and Sometimes Slow?

You swear you didn't change anything, but all of a sudden the SQL Server is going doggone slow. What happened? Parameter sniffing might be the problem, and to explain it, let's see how it works. I'm going to use the StackOverflow database - particularly, the Users table that I demo in How to Think Like the…

Read more about Why Is This Query Sometimes Fast and Sometimes Slow? 11 comments — Join the discussion