Automate INDEX rebuild based on fragmentation results?

后端 未结 4 1889
心在旅途
心在旅途 2021-02-02 00:26

Is it possible to add a maintenance job to check indexes fragmentation. If greater than 50% then rebuild those indexes automatically ?

Index size can vary from 100MB to

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-02 00:29

    You can use sys.dm_db_index_physical_stats to get information about your index fragmentation (see the avg_fragmentation_in_percent column). Then you can do an alter index with the rebuild clause whenever your threshold is reached.

提交回复
热议问题