Live registration reopens October 1, 2026, in 18d 01h 55mNotify me

Author: Erik Darling

Restoring tempdb since GETDATE(). Now blogging at ErikDarlingData.com.
Performance Tuning

When Query Plans Lie Part 2

Getting Weirder
In Part 1, we looked at how query plans can tell us little lies.

Now we're going to look at how those little lies can turn into bigger lies.
Adding An Index
Right now, this is our query:
[crayon-6aa5cc8440638924025265/]
If we add this filtered index, our query will have a grand ol' time using it;
[crayon-6aa5cc844063e154537544/]
Leaving aside my own advice about filtered indexes, what happens to the query plan now?

Read more about When Query Plans Lie Part 2 Be the first to comment
Performance Tuning

How Computed Columns Can Cause Blocking

The short story: when you add a computed column that references another table, like with a scalar user-defined function, you can end up causing concurrency problems even when people didn't really want to go see that other table, and that table is locked by someone else.

Here's my query:
[crayon-6aa5cc84415e9336860240/]
Here's what I occasionally see when the query runs, using sp_BlitzWho:

Read more about How Computed Columns Can Cause Blocking 5 comments — Join the discussion

So You Wanna Debug SQL Server Part 2

Birth Control
Debugging, and, heck, even learning about debugging, is a time-consuming and often unhelpful process when it comes to tracking down issues in SQL Server. It is arduous and tedious, and yields little chance of making you any friends. So why write about it?

Mostly because no one else is willing to -- at least not in the context of SQL Server. And, let's face it, "vibrant social life" has been used to describe me exactly zero times Kelvin.

Read more about So You Wanna Debug SQL Server Part 2 2 comments — Join the discussion
Performance Tuning

Index Key Column Order And Supporting Sorts

Whatever Man
When tuning queries that need to sort large amounts of data, sometimes it makes sense to stick the ordering elements as the leading key column(s) in your index. This allows SQL Server to easily sort your data by that column, and then access other key and included columns to satisfy other parts of the query, whether they're joins, predicates, or selected columns.

Read more about Index Key Column Order And Supporting Sorts 12 comments — Join the discussion
Performance Tuning

Hash Join Memory Grant Factors

Buskets
Much like Sorts, Hash Joins require some amount of memory to operate efficiently  -- without spilling, or spilling too much.

And to a similar degree, the number of rows and columns passed to the Hashing operator matter where the memory grant is concerned. This doesn't mean Hashing is bad, but you may need to take some extra steps when tuning queries that use them.

Read more about Hash Join Memory Grant Factors 8 comments — Join the discussion