Ola的默认IndexOptimizer作业会更新我的统计数据吗?

我刚刚安装了Ola Hallengren的MaintenanceSolution.sql维护脚本。在查看由IndexOptimize - USER_DATABASES任务生成的日志输出后,我担心它不会更新统计信息。我担心的原因是在日志输出中的参数列表中看到了@UpdateStatistics = NULL
Date and time: 2013-07-16 13:58:24
Server: XXXXX
Version: 10.0.5512.0
Edition: Standard Edition (64-bit)
Procedure: [PROD-PH].[dbo].[IndexOptimize]
Parameters: @Databases = 'USER_DATABASES', @FragmentationLow = NULL, @FragmentationMedium = 'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE', @FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE', @FragmentationLevel1 = 5, @FragmentationLevel2 = 30, @PageCountLevel = 1000, @SortInTempdb = 'N', @MaxDOP = NULL, @FillFactor = NULL, @PadIndex = NULL, @LOBCompaction = 'Y', @UpdateStatistics = NULL, @OnlyModifiedStatistics = 'N', @StatisticsSample = NULL, @StatisticsResample = 'N', @PartitionLevel = 'N', @MSShippedObjects = 'N', @Indexes = NULL, @TimeLimit = NULL, @Delay = NULL, @LockTimeout = NULL, @LogToTable = 'Y', @Execute = 'Y'
Source: http://ola.hallengren.com
这样做的动机是因为每个会计周期(每四周)都会运行一次查询,查询的日期范围是该周期。如果我不手动运行sp_updatestats,查询需要超过20分钟。如果统计信息是最新的,查询只需要不到5秒钟。所涉及的表大约有160万行,但每周只增长约2万行。因此,在给定的四周期间,它远未达到20%的自动阈值。其他几个表也有类似的增长模式。 我的计划是将此作业安排在每周运行一次。它会按需更新统计信息吗?
1个回答

默认情况下,脚本不执行统计维护。可以在此处找到有关脚本参数的文档here
Value   Description
================================
ALL     Update index and column statistics.
INDEX   Update index statistics.
COLUMNS Update column statistics.
NULL    Do not perform statistics maintenance. This is the default.
所以,如果你让主脚本为你创建维护作业,并且你想要更新索引和列的统计信息,那么你需要编辑IndexOptimize作业,并在过程调用中添加, @UpdateStatistics='ALL'