Rebuild indexes


Job details

Name: Rebuild indexes
Platform: Sqlserver
Category: Maintenance
Premium package: Maintenance package
Description: Rebuilds fragmented indexes in all databases.
Long description: The main effect of fragmentation is that it slows down page read-ahead throughput during index scans, which causes slower response times. If the query workload on a fragmented table or index involve scans, removing fragmentation will have effect.
Version: 2
Default schedule: 0 * * *
Requires engine install: Yes
Compatibility tag: .[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2005′ & hasengine=‘YES’]/.[eng_inst_priv = 0 & (engine_edition = ‘Microsoft SQL Server’ engine_edition = ‘Azure SQL Managed Instance’)]

Parameters

Name Default value Description
keep data for 180 Number of days to provide statistics for.
minimum fragmentation 30 The minimum fragmentation of the indexes to be rebuild.
minimum index size 1 The minimum index size (in MB) for indexes to be rebuild.
maximum index size 10000 The maximum index size (in MB) for indexes to be rebuild.
fill factor 90 The fill factor value (%). FILLFACTOR option is not allowed when rebuilding a columnstore index and will be ignored.
disable during working hours YES This parameter disables the alert to be scheduled, or to be run manually, during working hours (between 7am and 5pm).
rebuild clustered indexes YES Runs “ALTER INDEXREBUILD …” on clustered indexes.
rebuild non clustered indexes YES Runs “ALTER INDEXREBUILD …” on non clustered indexes.
max elap time 180 The maximum number of minutes before the dbWatch task stops rebuilding the remaining indexes.
ignore databases List of databases (separated by comma) which will be ignored. You can use % (percent sign) to represent wild card characters.
continue on next run YES If set to “YES“ (default) the rebuild indexes procedure will continue where it left off.
rebuild large indexes NO If set to “YES“ (default “NO”), the procedure starts with rebuilding of one index (the smallest one) from the list of indexes that were not rebuild because of too large size (larger than the “maximum index size” parameter value).
sort in tempdb ON By setting the parameter value to “ON” you can direct the SQL Server Database Engine to use tempdb to store the intermediate sort results that are used to build the index.
online OFF When set to “ON” allows to leave all indexes online and accessible while they are being rebuilt (runs ALTER INDEX … ON … REBUILD WITH (ONLINE=ON)). The online option for index rebuilds is only available in Enterprise edition. For other editions this parameter is ignored.

Job Summary

Key Procedures and Operations

Parameters Explanation (Excluded Detailed Listing)

Dependencies and Reporting

Implementation Overview

Compatibility and Execution Notes