Ola Index and Update stats

ola-hallengren

I wanted to ask what is the proper way to run the index maintannace ola script.
Do you include @UpdateStatistics = 'Y', and @OnlyModifiedStatistics = 'Y'?

The reason I ask is that wherever I read, everyone says not to update statistics after an index rebuild. From what I am seeing, with those two options highly fragmented or indexes that could not be reorganized, that were rebuild would have their stats updated (excluding column stats) and than updating stats again would update the stats.

Would it be better to update stats in a different job, ran at a different time/day or is it fin to include those options?

Best Answer

The parameters you're looking at are only used if indexes are reorganized.

Depending on the level of fragmentation involved, which you provide when you run the task, the IndexOptimize stored procedure will either rebuild indexes (which do not require statistics updates), or reorganize (which do require statistics updates).

There is a third scenario, where you can only update statistics, using the following code (from Ola's site):

EXECUTE dbo.IndexOptimize
@Databases = 'USER_DATABASES',
@FragmentationLow = NULL,
@FragmentationMedium = NULL,
@FragmentationHigh = NULL,
@UpdateStatistics = 'ALL',
@OnlyModifiedStatistics = 'Y';

Note that the Fragmentation options are explicitly set to NULL in this scenario.