Index Design and Access Paths

Clustered and nonclustered indexes, keys, included columns, and access paths.

113 associated posts109 primary posts

Performance Tuning

Forwarded Fetches and Bookmark Lookups

Base Table
When you choose to forgo putting  a clustered index on your table, you may find your queries utilizing forwarded fetches -- SQL Server's little change of address form for rows that don't fit on the page anymore.

This typically isn't a good thing, though. All that jumping around means extra reads and CPU that can be really confusing to troubleshoot.

Read more about Forwarded Fetches and Bookmark Lookups 4 comments — Join the discussion
Performance Tuning

Single-Column-Key Missing Index Recommendations are Usually Wrong.

When you're looking at an index recommendation - whether it's in an execution plan or the missing index DMVs - it helps to understand Clippy's blind spots. Let's start with the small StackOverflow2010 database so you can follow along. (It's just a 1GB direct download, and it expands to a 10GB database that reflects StackOverflow.com…

Read more about Single-Column-Key Missing Index Recommendations are Usually Wrong. 2 comments — Join the discussion
Performance Tuning

Does It Matter Which Field Goes First in an Index?

Let's take the dbo.Users table from the Stack Overflow database, which holds exactly what you think it holds - the list of users:

Say I want to count up all of the people with 1 reputation point:
[crayon-6a71e9eb0ad9d755274828/]
Without any indexes, that would scan the whole table. So to make it go faster, let's create an index on Reputation:
[crayon-6a71e9eb0ada8143141962/]
SQL Server uses the Reputation index for the count query:

Read more about Does It Matter Which Field Goes First in an Index? 9 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

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

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
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