SQL SERVER – Statistics Modification Counter – sys.dm_db_stats_properties

The Statistics Modification Counter tracks changes relevant to each statistics object. I inspect it alongside the affected query and estimates.

Separate pattern guides retain individual thread bundles for inspection rather than one combined change total.

A customer asked this question during a performance health check: which table had changed most since its statistics update? sys.dm_db_stats_properties gives us a practical place to start, with one row per statistics object.

SELECT OBJECT_SCHEMA_NAME(obj.object_id) AS schema_name,
       obj.name AS table_name, obj.object_id, stat.name AS statistics_name,
       stat.stats_id, sp.last_updated, sp.modification_counter
FROM sys.objects AS obj
JOIN sys.stats AS stat ON stat.object_id = obj.object_id
CROSS APPLY sys.dm_db_stats_properties(stat.object_id, stat.stats_id) AS sp
WHERE obj.type = 'U'
ORDER BY sp.modification_counter DESC, obj.object_id, stat.stats_id;

For ordinary disk-based tables, modification_counter tracks changes to the leading statistics column. Multiple statistics on the same table have separate counters. Don’t sum them and call the result a table-wide update count.

Historical output from the original statistics query. Table names, dates, and counts belong to that instance; the original query did not include the added schema-name column.
Historical output from the original statistics query. Table names, dates, and counts belong to that instance; the original query did not include the added schema-name column.

Interpret the result before changing statistics

last_updated identifies when the statistics blob was generated. It can be NULL when no blob exists. CROSS APPLY excludes statistics for which the function returns no row, including inaccessible objects.

The function reports statistics properties; it does not replace the histogram and density information shown by DBCC SHOW_STATISTICS. Memory-optimized tables also have different counter semantics, so check the documented scope.

A large counter or old date doesn’t prove a bad estimate. I inspect the query, histogram and actual versus estimated rows. Automatic updates help maintain statistics. Their thresholds and timing don’t replace investigation of a particular problem.

Related reading

A statistics counter is not a table-wide change total, it is a property of an individual statistics object.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL DMV, SQL Scripts, SQL Server, SQL Server DBCC, SQL Statistics
Previous Post
Scalar Function Statistics With sys.dm_exec_function_stats
Next Post
Partition Function Fanout: Count Partitions in SQL Server

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.