Statistics Management

Creating, updating, inspecting, and understanding optimizer statistics.

40 associated posts37 primary posts

Performance Tuning

It’s Okay If You Don’t Create Statistics.

Along with the ability to create indexes (which you most definitely should be doing), SQL Server gives you the ability to create statistics. This helps SQL Server guess how many rows will come back for your searches, which can help it make better decisions on seeks vs scans, which tables to process first, and how much memory a query will need.

Read more about It’s Okay If You Don’t Create Statistics. 9 comments — Join the discussion

[Video] Office Hours 2017/04/12 (With Transcriptions)

DISCLAIMER: this week, we learn that a naked Erik Darling looks like a bear covered in squid ink. Thankfully, we don't learn that via the webcams. Aside from that, Brent, Richie, and Erik also discuss updating stats and rebuilding indexes, feature request for Paste the Plan, included columns' effect on DML, CLR store procedures, SQL command and…

Read more about [Video] Office Hours 2017/04/12 (With Transcriptions) Be the first to comment
Performance Tuning

Filtered Statistics Follow-up

During our pre-con in Seattle
A really sharp lady brought up using filtered statistics, and for a good reason. She has some big tables, and with just 200 histogram steps, you can miss out on a lot of information about data distribution when you have millions or billions of rows in a table. There's simply not enough room to describe it all accurately, even with a full scan of the stats.

Read more about Filtered Statistics Follow-up 5 comments — Join the discussion

Hidden in SQL Server 2017 CTP v1.1: sys.dm_db_stats_histogram

It's Friday night, so I'm waiting for new CTP Releases
As soon as I got the email, I started reading the release notes. Some interesting stuff, of course.

Batch mode queries now support “memory grant feedback loops,” which learn from memory used during query execution and adjusts on subsequent query executions; this can allow more queries to run on systems that are otherwise blocking on memory.

Read more about Hidden in SQL Server 2017 CTP v1.1: sys.dm_db_stats_histogram 5 comments — Join the discussion

Stats Week: Only Updating Statistics With Ola Hallengren’s Scripts

I hate rebuilding indexes
There. I said it. It's not fun. I don't care all that much for reorgs, either. They're less intrusive, but man, that LOB compaction stuff can really be time consuming. What I do like is updating statistics. Doing that can be the kick in the bad plan pants that you need to get things running smoothly again.

Read more about Stats Week: Only Updating Statistics With Ola Hallengren’s Scripts 46 comments — Join the discussion

Why most of you should leave Auto-Update Statistics on

Oh God, he's talking about statistics again Yeah, but this should be less annoying than the other times. And much shorter. You see, I hear grousing. Updating statistics was bringin' us down, man. Harshing our mellow. The statistics would just update, man, and it would take like... Forever, man. Man. But no one would actually…

Read more about Why most of you should leave Auto-Update Statistics on 16 comments — Join the discussion

Changes to auto update stats thresholds in SQL Server 2016

TL;DR
As of CTP 3.3, it's the same behavior as Trace Flag 2371, in 2008 R2 SP1 and onward. That basically means that the bigger your table is, the fewer rows need to be modified before an automatic statistics update occurs.
Slightly longer...
The change was announced over here. At first I thought, woah, cool, they thought about this and made big changes. But no, much like Trace Flags 1117 and 1118 being enabled for tempdb, it's just...

Read more about Changes to auto update stats thresholds in SQL Server 2016 11 comments — Join the discussion
Performance Tuning

Are Index ‘Included’ Columns in Your Multi-Column Statistics?

When you create an index in SQL Server with multiple columns, behind the scenes it creates a related multi-column statistic for the index. This statistic gives SQL Server some information about the relationship between the columns that it can use for row estimates when running queries.

But what if you use 'included' columns in the index? Do they get information recorded in the statistics?

Read more about Are Index ‘Included’ Columns in Your Multi-Column Statistics? 3 comments — Join the discussion

Does Updating Statistics Cause a Recompile if No Data Has Changed?

tl;dr -- Not necessarily.

One of our students asked me a great question: if you update statistics on every table in the database, is that effectively the same as dumping the procedure cache on the instance? Will every execution plan have to be recompiled the next time it is run? I thought it was a great question and it spurred an interesting discussion about maintenance and recompilation.

Read more about Does Updating Statistics Cause a Recompile if No Data Has Changed? 4 comments — Join the discussion