Category: Indexing

Performance Tuning

Do Disabled Indexes Affect Missing Index Recommendations?

I'm so glad you asked! Let's take a look. Open up the Stack Overflow database, turn on actual execution plans, and run a query that will cause SQL Server to beg and plead for an index:
[crayon-6a65210a651cb572384894/]
And we get a missing index recommendation in the plan:

Now create the index, and try the query again:
[crayon-6a65210a651d6735868194/]
Oh, don't act like you haven't done that. And sure enough, SQL Server uses the index:

Read more about Do Disabled Indexes Affect Missing Index Recommendations? 8 comments — Join the discussion
Performance Tuning

Why Columnstore Indexes May Still Do Key Lookups

I was a bit surprised that key lookups were a possibility with ColumnStore indexes, since "keys" aren't really their strong point, but since we're now able to have both clustered ColumnStore indexes alongside row store nonclustered indexes AND nonclustered ColumnStore indexes on tables with row store clustered indexes, this kind of stuff should get a closer look.

Read more about Why Columnstore Indexes May Still Do Key Lookups 10 comments — Join the discussion
Performance Tuning

Optional Parameters and Missing Index Requests

That's when it all gets blown away
At one point or another in everyone's SQL-querying career, they end up writing a query that goes something like this:
[crayon-6a65210a71658311361710/]
These are often called optional parameters, and if you spend any time looking at queries, this will make you shudder for many reasons. Poor cardinality estimates, full scans, etc.

Read more about Optional Parameters and Missing Index Requests 11 comments — Join the discussion
Performance Tuning

Indexing for Windowing Functions: WHERE vs. OVER

Life Is Messy
Demo queries have this nasty habit of being clean. Even using a pit of despair like Adventure Works or World Wide Importers, it's easy to craft demo queries that fit the scenario you need to make yourself look like a genius. Stack Overflow, in all its simplicity, makes this even easier (lucky me!) because there's nothing all that woogy or wonky to dance around.

Read more about Indexing for Windowing Functions: WHERE vs. OVER 19 comments — Join the discussion
Performance Tuning

Creating Basic Indexes on the Stack Overflow Public Database

My public SQL Server database copy of the Stack Overflow data dump only includes clustered indexes by default. I want to keep your database size as small as possible for quick downloading.

But like any database - when you create it, should you add your own indexes to make queries go faster? The answer lies in knowing your workloads, but we don't usually know our database workloads until they start.

Read more about Creating Basic Indexes on the Stack Overflow Public Database Be the first to comment

Should You Enforce Foreign Key Relationships in the Database?

It's one of those fierce religious wars that divides families and tears loved ones apart. First, if two tables are related, should we tell SQL Server about it? If SQL Server knows that there's a relationship, then it can make better decisions when building execution plans. The problem is that SQL Server has to be…

Read more about Should You Enforce Foreign Key Relationships in the Database? 21 comments — Join the discussion
Performance Tuning

ColumnStore Indexes: Rowgroup Elimination and Parameter Sniffing In Stored Procedures

Yazoo
Over on his blog, fellow Query Plan aficionado Joe Obbish has a Great Post, Brent® about query patterns that qualify for Rowgroup Elimination. This is really important to performance! It allows scans to skip over stuff it doesn't need, like skipping over the dialog in, uh... movies with really good fight scenes.

Car chases?

Read more about ColumnStore Indexes: Rowgroup Elimination and Parameter Sniffing In Stored Procedures 5 comments — Join the discussion
Performance Tuning

How to Drop All Your Indexes – Fast

Sometimes I need to reset stuff during performance training classes. I know some of you teach classes, too, and some of you just like doing crazy stuff. So here you go, a stored procedure to lose weight fast: DropIndexes for SQL Server 2016 & Newer [crayon-6a65210a72f6d868265856/] DropIndexes for SQL Server 2008-2014 This one doesn't include…

Read more about How to Drop All Your Indexes – Fast 28 comments — Join the discussion
Performance Tuning

Five Mistakes Performance Tuners Make

There's no Top in the title

And that's because a TOP without an ORDER BY is non-deterministic, and you'll get yelled at on the internet for doing that. This is just a short collection of things that I've done in the past, and still find people doing today when troubleshooting performance. Sure, this list could be a lot longer, but I only have the attention span to blog.

Read more about Five Mistakes Performance Tuners Make 9 comments — Join the discussion
Performance Tuning

Why Missing Index Recommendations Aren’t Perfect

Using the good ol' Stack Overflow public database, get the execution plan for this query - either estimated or actual, doesn't matter:
[crayon-6a65210a759c3568977991/]
In the execution plan, SQL Server asks for a missing index on the LastAccessDate field:

If you right-click on the plan and click Show Execution Plan XML, you get more technical details:

Read more about Why Missing Index Recommendations Aren’t Perfect 6 comments — Join the discussion