Indexing

Category: indexing

Comparing Single Column, Multi-Column, and Filtered Statistics in SQL Server

Comparing Single Column, Multi-Column, and Filtered Statistics in SQL Server

Statistics in SQL Server are simple in theory: they help the optimizer estimate how many rows a query might return.

In practice? Things get weird fast. Especially when you start filtering on multiple columns, or wondering why the optimizer thinks millions of rows are coming back when you know it’s more like a few hundred thousand.

In this post, I’ll walk through examples using single-column, multi-column, and filtered statistics—and show where estimates go off the rails, when they get back on track, and why that doesn’t always mean you need to update everything with FULLSCAN.

Continue reading

Ugly Bug: SQL Server Online Index Rebuild Sometimes Happens Offline Without Warning

Ugly Bug: SQL Server Online Index Rebuild Sometimes Happens Offline Without Warning

🔥 UPDATE: This issue has now been documented. A note has been added to the Perform index operations online documentation page, stating: "Index rebuild commands might hold exclusive locks on clustered indexes after a large object column is dropped from a table, even when performed online."

I found a nasty bug in SQL Server and Azure SQL Managed Instance recently: sometimes an ‘online’ index rebuild of a disk-based rowstore clustered index (basically a normal, everyday table) isn’t actually ‘online". In fact, it’s very OFFLINE, and it blocks both read and write queries against the table for long periods.

If you manage to make it through a rebuild successfully, the problem goes away for future rebuilds of that clustered index – likely leaving you bruised and bewildered.

Continue reading

Should We Do Index Maintenance on an Azure SQL Managed Instance or Azure SQL Database?

Should We Do Index Maintenance on an Azure SQL Managed Instance or Azure SQL Database?

Have you ever received advice that was technically correct, but it was too hard to understand?

I think of this as “accidental bad advice,” because it can lead to confusion and bad outcomes. There’s a LOT of accidental bad advice out there on index maintenance for SQL Server and cloud versions like Azure SQL, even in the official documentation.

In this post I’m answering a common index maintenance question, and we’re going to keep it simple.

Continue reading

New Article on Performance Tuning with the Missing Indexes Feature in SQL Server

New Article on Performance Tuning with the Missing Indexes Feature in SQL Server

We’ve just published a new article in the SQL docs, Tune nonclustered indexes with missing index suggestions . The article explains what the missing index feature is, limitations of the feature, and how to use missing index DMVs and missing index suggestions in Query Store to tune indexes.

Continue reading

Index Design Guide Updated: Index Types, B+ Trees, and Row Locators, Oh My

Index Design Guide Updated: Index Types, B+ Trees, and Row Locators, Oh My

We’ve recently updated the SQL Server and Azure SQL index architecture and design guide. This article is an in-depth guide to indexing in databases using the SQL Server engine, including SQL Server, Azure SQL Database, Azure SQL Managed Instance, and Azure Synapse Analytics.

Our recent update adds a table to categorize the types of indexes discussed in the article, clarifies B-trees vs B+ trees, and describes how row locators (aka “secret columns”) are used in nonclustered indexes.

Continue reading

Outlining My Session: Index Tuning in an Agile World

Outlining My Session: Index Tuning in an Agile World

I’m giving a session on index tuning at the upcoming Redgate Streamed free online conference. The conference will be held April 1-3 2020, register here and join us!

I love talking about index tuning and I know this area well, so I’m excited to put together this new session. I thought it would be fun to share my process of outlining and creating the session, leading up to the event.

Continue reading

SQL PASS Summit 2017 Day 2 - Keynote Notes and Ideas

SQL PASS Summit 2017 Day 2 - Keynote Notes and Ideas

on November 2, 2017

Category: indexing

This morning, Dr Rimma Nehme tells us the story of the birth of Azure Cosmos DB, a global, scale-out database system.

Continue reading