Live classes start in 1d 06h 07m — Save your seat

Index Evaluation and Specialized Indexes

Missing-index advice, filtered indexes, columnstore, and over-indexing.

62 associated posts59 primary posts

Performance Tuning

Checking for Strange Client Settings with sys.dm_exec_sessions

In my performance training class, people get really excited when I cover filtered indexes, computed columns, and indexed views.

Then they get a really strange expression on their face when I talk about one of the biggest drawbacks: if your connection options aren't set correctly, your delete/update/insert (DUI) operations will fail. That gave me a really fun time once when I implemented an indexed view, and they called me back the next day screaming because their app was down. My bad. (sigh)

Read more about Checking for Strange Client Settings with sys.dm_exec_sessions 11 comments — Join the discussion

[Video] Office Hours 2017/02/08 (With Transcriptions)

This week, Brent, Erik, Tara, and Richie discuss compatibility levels, SQL server SPN problems, Always On Availability Groups, failover clustering, capturing DML stuff, disc defragmentation, replication snapshots and reindexing, load testing, PowerShell, and whether you should pursue the path of a DBA.

Here’s the video on YouTube:

Read more about [Video] Office Hours 2017/02/08 (With Transcriptions) 3 comments — Join the discussion
Performance Tuning

Filtered Indexes and Variables: Less Doom and Gloom

It Is Known
That when you use filtered indexes, they get ignored when your queries are parameterized. This is a Plan Caching Thing©, of course. The simplest example is a bit column with a filtered index. If your index is on WHERE Bit = 1, it doesn't have data for WHERE Bit = 0. That index would only be suitable for one variation of the query, so caching a plan that uses an index which can't be reused for every variation isn't feasible.

Read more about Filtered Indexes and Variables: Less Doom and Gloom 5 comments — Join the discussion
Performance Tuning

Where Do Missing Index Requests Come From?

Be honest, here You don't care about most indexing problems. Duplicates, Borderline Duplicates, Unused, Wide, Non-aligned Partitions... All you're here for are the Missing Indexes. Wham, bam, your query finishes in less than a second, ma'am. Take this quarter, go downtown and have a rat gnaw that thing off your face. And I get it.…

Read more about Where Do Missing Index Requests Come From? 1 comment — 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

Using “OR” and “IN” with SQL Server’s Filtered Indexes

You can't do everything with filtered indexes in SQL Server. For instance, you can't create the following index:
[crayon-6ae6a960053e4390500932/]
If you try, you'll get the error message:
[crayon-6ae6a960053ea930756826/]
Instead, you can use 'IN' and create the index this way:
[crayon-6ae6a960053ed320210675/]
That works-- and good news, even queries written with 'OR' can use that filtered index, because SQL Server is clever like that. Here's an execution plan that shows it in action.

Read more about Using “OR” and “IN” with SQL Server’s Filtered Indexes 4 comments — Join the discussion
Performance Tuning

How to Add Nonclustered Indexes to Clustered Columnstore Indexes

SQL Server 2012 introduced nonclustered columnstore indexes, but I never saw them used in the wild simply because once created, they made the underlying table read-only. Not a lot of folks like read-only tables. (Bad news, by the way - that limitation hasn't disappeared in 2014.) SQL Server 2014 brings clustered columnstore indexes, and they're…

Read more about How to Add Nonclustered Indexes to Clustered Columnstore Indexes 15 comments — Join the discussion
Performance Tuning

Filtered Indexes vs. Table Partitioning

It was a dark and stormy… Oh, wrong story. It was actually a warm, sunny afternoon in Charlotte, NC. I was presenting “Index Methods You’re Not Using” at PASS Summit. In this talk, I discussed how indexed views, filtered indexes, and compressed indexes can improve your query performance by reducing I/O.

From stage right, an intrepid audience member raised his hand and asked, “Can you think of an example of when you would use filtered indexes instead of partitioning?”

Read more about Filtered Indexes vs. Table Partitioning 7 comments — Join the discussion
Performance Tuning

What You Can (and Can’t) Do With Indexed Views

Views are logical objects in SQL Server databases that present you with a “virtual table”. Views are typically created for one of three reasons: security, simplification, or aggregation. Security: we create views so that a user can read specific columns out of certain tables, but not all the data. Simplification: sometimes, it’s easier to write…

Read more about What You Can (and Can’t) Do With Indexed Views 32 comments — Join the discussion
Performance Tuning

Filtered Indexes and Dynamic SQL

I’ve been told that an attendee at the PASS Summit pre-conference event asked about using dynamic SQL to get around some of the problems with filtered indexes. I’m not entirely sure what the question was, but it did give me the opportunity to play around with filtered indexes and write some simple demo code to illustrate just the kind of shenanigans that you can get up to.

Read more about Filtered Indexes and Dynamic SQL 21 comments — Join the discussion