Indexing and Statistics

Designing, evaluating, maintaining, and troubleshooting indexes and statistics.

568 associated posts270 primary posts

[Video] Office Hours: Long Answers Edition

This week's top-voted questions from https://pollgab.com/room/brento finds us opening ChatGPT multiple times! It's fun to show how I use it, and what it thinks of me.

Prefer listening to this via podcast? Good news! You can now subscribe to Office Hours on Spotify, Apple Podcasts, Podcast Index, Podcast Addict, Podchaser, and anywhere else fine podcasts are sold.

Read more about [Video] Office Hours: Long Answers Edition Be the first to comment

Database Animations: You’ve Heard of Page Splits. Here’s What They Really Mean.

You've heard that page splits are bad, and they're an indication that your table design is making your storage work too hard. You've heard that the right answer to fix it is adjusting fill factor lower, or doing regular index maintenance.

Before you watch the below animation, you'll wanna get up to speed with how index seeks work. Then, let's explain page splits with an animation:

Read more about Database Animations: You’ve Heard of Page Splits. Here’s What They Really Mean. 15 comments — Join the discussion

How Multi-Column Statistics Work

The short answer: in the real world, only the first column works. When SQL Server needs data about the second column, it builds its own stats on that column instead (assuming they don't already exist), and uses those two statistics together - but they're not really correlated.

For the longer answer, let's take a large version of the Stack Overflow database, create a two-column index on the Users table, and then view the resulting statistics:

Read more about How Multi-Column Statistics Work 4 comments — Join the discussion

[Video] Office Hours: Q&A on the Mountaintop

Well, maybe mountain is a bit of a strong word, but it's one of the highest elevation home sites in Las Vegas, with beautiful views over the valley, the Strip, the airport, and the surrounding mountains. Let's go through your top-voted questions from https://pollgab.com/room/brento while taking in the view - and you can move the camera around, since this is an Insta360 video.

Read more about [Video] Office Hours: Q&A on the Mountaintop 4 comments — Join the discussion
Performance Tuning

Row-Level Security Can Slow Down Queries. Index For It.

The official Azure SQL Dev's Corner blog recently wrote about how to enable soft deletes in Azure SQL using row-level security, and it's a nice, clean, short tutorial. I like posts like that because the feature is pretty cool and accomplishes a real business goal. It's always tough deciding where to draw the line on how much to include in a blog post, so I forgive them for not including one vital caveat with this feature.

Read more about Row-Level Security Can Slow Down Queries. Index For It. 3 comments — Join the discussion

Logical Reads Aren’t Repeatable on Columnstore Indexes. (sigh)

Sometimes I really hate my job. Forever now, FOREVER, it's been a standard thing where I can say, "When you're measuring storage performance during index and query tuning, you should always use logical reads, not physical reads, because logical reads are repeatable, and physical reads aren't. Physical reads can change based on what's in cache,…

Read more about Logical Reads Aren’t Repeatable on Columnstore Indexes. (sigh) 12 comments — Join the discussion

[Video] Office Hours: Back in the Bahamas Edition

Yes, I'm back on a cruise ship with another 360 degree video. Lest you think I'm being wildly irresponsible (or responsible perhaps?) with your consulting and training money, be aware that this particular cruise was free thanks to the fine folks in the casino department at Norwegian Cruise Lines. In between beaches and blackjack, let's go through your top-voted questions from https://pollgab.com/room/brento.

Read more about [Video] Office Hours: Back in the Bahamas Edition 1 comment — Join the discussion

Automatic Stats Updates Don’t Always Invalidate Cached Plans

Normally, when SQL Server updates statistics on an object, it invalidates the cached plans that rely on that statistic as well. That's why you'll see recompiles happen after stats updates: SQL Server knows the stats have changed, so it's a good time to build new execution plans based on the changes in the data.

However, updates to system-created stats don't necessarily cause plan recompiles.

Read more about Automatic Stats Updates Don’t Always Invalidate Cached Plans 9 comments — Join the discussion

[Video] Office Hours in Kyoto, Japan

Kyoto feels like a timeless, classic version of historical Japan with quiet tree-lined streets, giant temples, and bubbling brooks. It's the exact opposite of last week's experience in noisy Osaka! Last year, I filmed in Kyoto outside a temple, and this year, I'm at another temple just after New Year's, the time when Japanese folks traditionally go to visit their many gorgeous temples.

Read more about [Video] Office Hours in Kyoto, Japan 3 comments — Join the discussion