首页 / MSSQL / sqlserver统计信息自动更新
sqlserver统计信息自动更新
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了sqlserver统计信息自动更新,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1822字,纯文字阅读大概需要3分钟。
内容图文
![sqlserver统计信息自动更新](/upload/InfoBanner/zyjiaocheng/531/2eb25814b8194c8a9f54c0f2df6fdd74.jpg)
对于已经应用的表(非临时表)统计信息更新条件为500+20%,具体更新条件 If the statistics is defined on a regular table, it is out of date if: The table size has gone from 0 to 0 rows. The number of rows in the table when the statistics were gath
对于已经应用的表(非临时表)统计信息更新条件为500+20%,具体更新条件
If the statistics is defined on a regular table, it is out of date if:
-
The table size has gone from 0 to >0 rows.
-
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.
-
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.
-
If the statistics object is defined on a temporary table, it is out of date as discussed above, except that there is an additional threshold for recomputation at 6 rows, with a test otherwise identical to test 2 in the previous list.
在一些较大的表中触发此更新条件的周期可能较长,因为可能影响查询的性能.在此介绍sqlserver 的一个trace flag 2371
当开启这个flag时,统计信息的更新将会根据表数据量的总体大小动态调整触发更新条件
(如1000000数据 30000就会触发更新(3%),1000000000数据1000000就会触发(0.1%)),从而有可能提高系统整体性能.
如图所示
注意:由于更新统计信息本身也是有一定得资源消耗,开启后会造成统计信息更新相对频繁,所以开启前应全面评估整体成本.
(如未因统计信息更新对全局造成明显影响则无需开启)
个人想法:关系型数据库发展至今,所有产品差别越来越小,细节更能体现一款产品的优秀程度.
2371的特性如果能作为一个库的option设置,细化粒度(数据库根据用途可能导致访问特点不尽相同),将会使统计信息的管理更合理灵活.
内容总结
以上是互联网集市为您收集整理的sqlserver统计信息自动更新全部内容,希望文章能够帮你解决sqlserver统计信息自动更新所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。