Are the statistics being updated?

The auto-update statistics configuration updates statistics when the amount of row changes in the table achieves 20% of total rows.

However, for tables with too many rows, this threshold is too high. For example, a table with 1 million rows will only update statistics after 200 thousands changes. That’s too much and can affect query plans and query performance.

We can enable trace flag 2371 to change this behavior. Using this trace flag, threshold to trigger the auto-update statistics become dynamic. After 25k rows in the table, the amount of updates starts to decrease. A table with 1M rows needs around 3.2% of updates to trigger the auto-update statistics.

Even with this trace flag enabled, an important administrative task is identifying if the auto-update statistics is running often enough and, if not, schedule the update statistics using a SQL Agent job.

We can find when the last update statistics happened and how many row modifications happened since the last update statistics using sys.dm_db_stats_properties DMV with a few more joins.

Let’s create a user defined function to make all the work easier. The function StatisticsModifications will retrieve information about all statistics in the database:

Now we can use this function with some filters to retrieve the most out dated statistics.

Using the result of the above query you can identify if the update statistics are running in regular intervals or if you need to schedule the update statistics.