Statistics Management

Creating, updating, inspecting, and understanding optimizer statistics.

40 associated posts37 primary posts

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: 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] Halloween Office Hours in Salem, MA

I visited friends in Salem, Massachusetts, home of the 1692 witch trials, and it turns out Salem is a great place to visit around Halloween! There were tours, characters in costume, witch gear shops, and all kinds of spooky-themed happenings.

I sat down outside of the Charter Street Cemetery to take your top-voted questions from https://pollgab.com/room/brento:

Read more about [Video] Halloween Office Hours in Salem, MA 2 comments — Join the discussion

Does the Rowmodctr Update for Non-Updating Updates?

Update May 20 - make sure to read to the end for an update.

Okay, look, it's a mouthful of a blog post title, and there are only gonna be maybe six of us in the world who get excited enough to check this kind of thing, but if you're in that intimate group, then the title's already got you interested in the demo. (Shout out to Riddhi P. for asking this cool question in class.)

Read more about Does the Rowmodctr Update for Non-Updating Updates? 11 comments — Join the discussion