Category: Indexing

Why most of you should leave Auto-Update Statistics on

Oh God, he's talking about statistics again Yeah, but this should be less annoying than the other times. And much shorter. You see, I hear grousing. Updating statistics was bringin' us down, man. Harshing our mellow. The statistics would just update, man, and it would take like... Forever, man. Man. But no one would actually…

Read more about Why most of you should leave Auto-Update Statistics on 16 comments — Join the discussion
Performance Tuning

Unique Indexes and Row Modifications: Weird

Confession time This started off with me reading a blurb in the release notes about SQL Server 2016 CTP 3.3. The blurb in question is about statistics. They're so cool! Do they get fragmented? NO! Stop trying to defragment them, you little monkey. Autostats improvements in CTP 3.3 Previously, statistics were automatically recalculated when the…

Read more about Unique Indexes and Row Modifications: Weird 3 comments — Join the discussion
Performance Tuning

Filtered Indexes: Just Add Includes

I found a quirky thing recently While playing with filtered indexes, I noticed something odd. By 'playing with' I mean 'calling them horrible names' and 'admiring the way other platforms implemented them'. I sort of wrote about a similar topic in discussing indexing for windowing functions. It turns out that a recent annoyance could also…

Read more about Filtered Indexes: Just Add Includes 30 comments — Join the discussion
Performance Tuning

Trace Flag 2330: Who needs missing index requests?

Hey, remember 2005?
What a great year for... not SQL Server. Mirroring was still a Service Pack away, and there was an issue with spinlock contention on OPT_IDX_STATS or SPL_OPT_IDX_STATS. The KB for it is over here, and it's pretty explicit that the issue was fixed in 2008, and didn't carry over to any later versions. For people still on 2005, you had a Trace Flag: 2330.

Read more about Trace Flag 2330: Who needs missing index requests? 7 comments — Join the discussion
Performance Tuning

Does Creating an Indexed View Require Exclusive Locks on an Underlying Table?

An interesting question came up in our SQL Server Performance Tuning course in Chicago: when creating an indexed view, does it require an exclusive lock on the underlying table or tables? Let's test it out with a simple indexed view run against a non-production environment. (AKA, a VM on my laptop running SQL Server 2014.)…

Read more about Does Creating an Indexed View Require Exclusive Locks on an Underlying Table? Be the first to comment
Performance Tuning

Is leading an index with a BIT column always bad?

“Throughout history, slow queries are the normal condition of man. Indexes which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people who don't think bit columns are selective enough to…

Read more about Is leading an index with a BIT column always bad? 5 comments — Join the discussion
Performance Tuning

Clustered Index key columns in Nonclustered Indexes

Clustered indexes are fundamental
And I'm not just saying that because Kendra is my spiritual adviser!

They are not ~a copy~ of the table, they are the table, ordered by the column(s) you choose as the key. It could be one. It could be a few. It could be a GUID! But that's for another time. A long time from now. When I've raised an army, in accordance with ancient prophecy.

Read more about Clustered Index key columns in Nonclustered Indexes 26 comments — Join the discussion
Performance Tuning

Finding Tables with Nonclustered Primary Keys and no Clustered Index

i've seen this happen
Especially if you've just inherited a database, or started using a vendor application. This can also be the result of inexperienced developers having free reign over index design.

Unless you're running regular health checks on your indexes with something like our sp_BlitzIndex® tool, you might not catch immediately that you have a heap of HEAPs in your database.

Read more about Finding Tables with Nonclustered Primary Keys and no Clustered Index 31 comments — Join the discussion
Performance Tuning

New Cardinality Estimator, New Missing Index Requests

During some testing with SQL Server 2014's new cardinality estimator, I noticed something fun: the new CE can give you different index recommendations than the old one. I'm using the public Stack Overflow database export, and I'm running this Jon Skeet comparison query from Data.StackExchange.com. (Note that it has something a little tricky at the…

Read more about New Cardinality Estimator, New Missing Index Requests 3 comments — Join the discussion
Performance Tuning

Indexing for GROUP BY

It's not glamorous And on your list of things that aren't going fast enough, it's probably pretty low. But you can get some pretty dramatic gains from indexes that cover columns you're performing aggregations on. We'll take a quick walk down demo lane in a moment, using the Stack Overflow database. Query outta nowhere! [crayon-6a6387ceeacbd015680452/]…

Read more about Indexing for GROUP BY 9 comments — Join the discussion
Performance Tuning

Are Index ‘Included’ Columns in Your Multi-Column Statistics?

When you create an index in SQL Server with multiple columns, behind the scenes it creates a related multi-column statistic for the index. This statistic gives SQL Server some information about the relationship between the columns that it can use for row estimates when running queries.

But what if you use 'included' columns in the index? Do they get information recorded in the statistics?

Read more about Are Index ‘Included’ Columns in Your Multi-Column Statistics? 3 comments — Join the discussion