[英]Why statistics have not been recomputed?
I have SQL Server Compact Edition 4.0 database that get ~1K records every day. 我有SQL Server Compact Edition 4.0数据库,每天都能获得约1000条记录。 But over time some queries lost their efficency. 但是随着时间的流逝,一些查询失去了效率。 I re-checked indexes and statistics and found that the statistics were not updated long time. 我重新检查了索引和统计信息,发现统计信息并没有长时间更新。 sp_show_statistics
shows me the following: sp_show_statistics
向我显示以下内容:
TABLE INDEX UPDATED ROWS ROWS__SAMPLED STEPS DENSITY AV_KEY_LEN RECOMPUTE STALE
Events PK_Events 18.08.2015 7:45:08 1876754 1876754 5 5,328349E-07 4 True False
Files PK_Files 09.08.2015 18:15:00 411589 411589 3 2,429608E-06 4 True False
Revisions PK_Revisions 07.07.2015 8:10:05 376296 376296 5 2,657482E-06 4 True False
Revisions UQ_Revisions_Guid 07.07.2015 8:10:50 376296 376296 200 2,657482E-06 16 True False
...
From MSDN (sp_show_statistics): 从MSDN(sp_show_statistics):
RECOMPUTE. 建议。 A Boolean value. 布尔值。 True indicates that this statistic will be automatically updated the next time it is used, if it is determined to be stale. 如果为True,则表示如果确定该统计信息已过时,则下次使用该统计信息时将自动对其进行更新。
All indexes were created without STATISTICS_NORECOMPUTE option. 创建所有索引时都没有STATISTICS_NORECOMPUTE选项。 Database is used intensively every day. 每天都会大量使用数据库。 One more detail: Revisions table now has 442067 records, but statistics for this table were build on 376296 rows as I see in sp_show_statistics output. 更详细一点:版本表现在具有442067条记录,但是该表的统计信息建立在376296行上,正如我在sp_show_statistics输出中看到的那样。
How I can keep the statistics up-to-date? 如何使统计信息保持最新状态? Thanks! 谢谢!
You can use "UPDATE STATISTICS" 您可以使用“更新统计信息”
https://technet.microsoft.com/en-us/library/ms174025(v=sql.110).aspx https://technet.microsoft.com/zh-CN/library/ms174025(v=sql.110).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.