How often are SQL Server Index Usage Stats Updated and what triggers it?

百般思念 提交于 2020-01-13 13:50:49

问题


There are some other similar question to this but, please, do not confuse.

I know there's a function STATS_DATE() to know where the stats where updated, which is fine, but what I want to know is what triggers an update of this stats, or a cut-off. I know there's a report for this as well.

But last week I saw the stats in certain server and they gave me very good information with amounts of 4 digits for the main tables in this particular database.

Right now looking in the same production server and the STATS_UPDATE function returned they were updated last Saturday, but this server has been up for weeks without reboot not even service restart. So I know I'm looking the stats accumulated basically just this Monday morning.

So, I would like to know where can I set this settings so the server keeps accumulating the index usage stats until I clear the log or whatever storage it use.


回答1:


There are various "stats" that SQL server maintains for Tables and indexes.

  1. Histogram statistics. Thes are the stats that the query optimizer uses. STATS_DATE() returns the last date/time these were updated. The criteria for automatic updating of histogram statistics is 500 rows + 20% of the table. So a table with 100,000 rows, you'd have to update 20,500 rows before triggering a recalculation of these. You can't change the threshold for automatic statistic updating, however, you can turn off automatic statistic updating and/or manually update statistics on particular tables and indexes.

  2. Usage statistics: These are found in sys.dm_db_index_usage_stats. Index usage statistics keep track of things like seeks and scans from SELECT queries. They are not persisted and get reset on restart of sql server. These statistics also get reset if the underlying index is rebuilt "ALTER INDEX ... REBUILD", but not with "ALTER INDEX ... REORG"

  3. Operational Statistics: These are found in sys.dm_db_index_operational_stats. Operational statistics are things such as page splits, leaf level inserts and PAGEIOLATCH delay. These are also non persisted.



来源:https://stackoverflow.com/questions/13689186/how-often-are-sql-server-index-usage-stats-updated-and-what-triggers-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!