Sql-server – How to update the statistics of an index that has just been reorganized, both with IndexOptimize script

index-statisticssql server

I would like to know if we can update the statistics of an index that has been reorganized, using the IndexOptimize script.
Indeed, an index that is reorganized needs to have its statistics updated. Is there a way to use IndexOptimize script to update the statistics of this reorganized index only?
For instance, is there a flag to recognize the reorganized index in order to update the statistics on this flagged index?
Thanks.

Best Answer

I take it that you are referring to Ola Hallengren's scripts.

I can't find any parameter combo that would do what you ask. It is a pretty reasonable thing to ask for, though. IndexOptimize is pretty much separate in the handling of defrag vs updstats. Your options, as far as I can see:

  • Modify the proc yourself. It is only TSQL, in the end. Add an UPDATE STATISTICS after it does index reorg.
  • Create a branch on GitHub and see if it is merged into the main bransch. Now others can enjoy your effort (like we all are enjoying Ola's effort).
  • Send an email to Ola and see if he feels like doing the change.
  • Schedule a separate job for statistics - but you won't get the coupling to the previous reorg.
  • Choose a different maint solution.
  • Measure whether you actually gain anything from defrag, and potentially focus on statistics update instead.

Possibly some more, but those are the ones I can think of right now. :-)