1

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?

1
  • You can get into the weeds with this, but I'd just start with: Does running both in the same job allow it to run within a reasonable amount of time? If so, keep it simple and run them together. If you want to update stats more often in addition to a weekly index maintenance, for example, then go ahead and do that. But if it isn't a problem, then don't worry about it. Feb 9, 2018 at 22:22

1 Answer 1

2

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.

2
  • I guess my question is more of, does the IndexOptimize stored procedure update statistics only on indexes it reorganized or does it do it regardless if you pass the two parameters to update statistics along with the Index reorg/rebuild parameters. Feb 12, 2018 at 14:21
  • I thought my first sentence answers that question. If it’s not clear, please let me know. Feb 14, 2018 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.