Category: Indexing

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-6a63926e31b81574699989/]
If we add this filtered index, our query will have a grand ol' time using it;
[crayon-6a63926e31b87790807170/]
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

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

Missing Index Impact and Join Type

Just Another Way
No matter how you delve into missing index requests -- whether it's the plan level, DMV analysis, or (forgive me for saying it), DTA, the requests will generally be the same.

They'll prioritize equality predicates, the columns may or not may be in the right order, the columns may or may not be in the right part of the index, and the impact...

Read more about Missing Index Impact and Join Type 8 comments — Join the discussion
Performance Tuning

Memory Grants: SQL Server’s Other Public Toilet

Sharing Is Caring
When everything is going well, and queries are behaving responsibly, one need hardly think about memory grants.

The problem becomes itself when queries start to over and under estimate their practical needs.
Second Hand Emotion
Queries ask for memory to do stuff. Memory is a shared resource.

Read more about Memory Grants: SQL Server’s Other Public Toilet 13 comments — Join the discussion
Performance Tuning

Functions Can Still Use Indexes, Kinda.

This sentence gets repeated a lot. You know the one: "Functions prevent the use of indexes." Well, knowing you, it's probably just your indexes. I've seen your indexes.

Functions can use indexes, but even so, that doesn't mean that they're going to perform as well as queries without functions.
Which Indexes?
In the SUPERUSER database (yeah, I know, I'm cheating on Stack Overflow), all the tables have a PK/CX on an Id column, which is an Identity.

Read more about Functions Can Still Use Indexes, Kinda. 16 comments — Join the discussion