Why are these SQL Server statistics outdated, when it's set to auto-update?

倖福魔咒の 提交于 2019-12-23 19:24:00

问题


We have a SQL Server 2012 instance, with auto-statitics set to ON for the DB:

But then i ran a query to check some statistics, and some haven't been updated in a while:

  1. Why is this the case? Is there a rule to whether SQL Server updates statistics that haven't been triggered by these indexes?
  2. Do i need to care? How do i know if i need to update them, or if they are causing performance issues for me?

Thanks!


回答1:


Even though you set Auto update statistics to true, they will update only when a threshold has been reached..this is different for different versions

Thresholds for SQL Server 2012 or older:

  1. The table size has gone from 0 to > 0 rows

  2. The number of rows in the table when the statistics were gathered was 500 or less, and the colmodctr of the leading column of the statistics object has changed by more than 500 since then

  3. The table had more than 500 rows when the statistics were gathered, and the colmodctr of the leading column of the statistics object has changed by more than 500 + 20% of the number of rows in the table when the statistics were gathered

For SQLServer 2016,there are few major changes and SQL Updates statistics with a new algorithm(read as more frequently than old versions)

Do i need to care? How do i know if i need to update them, or if they are causing performance issues for me?

Normally people schedule maintenance jobs during weekends and this includes index rebuild/stats update..

This should normally take care of most databases.In your case,if you are seeing performance issues due to invalid stats,you can update them manually.We do it once a week,but sites like StackOverflow does it more often

update stats tablename

Further reading/references:
Statistics Used by the Query Optimizer in Microsoft SQL Server 2008
Understanding When Statistics Will Automatically Update



来源:https://stackoverflow.com/questions/45706088/why-are-these-sql-server-statistics-outdated-when-its-set-to-auto-update

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