# Index Reorganize and Index Rebuild

Index reorganize and Index rebuild are set up as jobs in the SQL Server Agent. There are separate jobs for the ACDC database and the ACDC CDM database. The reorganize job should be run once a day on a database. In a transaction heavy system, the rebuild job should be run once a week. The user can modify the job schedule for both jobs and also specify how long a job is allowed to execute in a single run. Both jobs will always run reorganize/rebuild in a specific order, starting with the heaviest fragmented index first.

For the Index Rebuild job, the user can specify:

- RebuildPercentageLimit: This sets the job to only rebuild indexes defraged with a percentage of this limit or above.

- RebuildStopTime: This sets the stop time for the index rebuild job relative to the scheduled start time. This specifies the maximum time the job is allowed to execute. The job will not stop at this time, it will finish up the current index rebuild but no additional indexes will be processed after. Example: The job is scheduled to start at 23:00 and should not run any longer than three hours, then the RebuildStopTime should be set to 02:00.

- MinPageCount: This sets the job only to reorganize indexes with a page size equal to this limit or above.

For the Index Reorganize job, the user can specify:

- LowerReorganizePercentageLimit: This sets job to only reorganize indexes defraged with a percentage of this limit or above

- UpperReorganizePercentageLimit: This sets the job to only reorganize indexes defraged with a percentage of this limit or lower.

- ReorganizeStopTime: This sets the stop time for the index reorganize job relative to the scheduled start time. This specifies the maximum time the job is allowed to execute. The job will not stop at this time, it will finish up the current index reorganization but no additional indexes will be processed after. Example: The job is scheduled to start at 20:00 and should not run any longer than two hours, then the ReorganizeStopTime should be set to 22:00.

- MinPageCount: This sets the job only to reorganize indexes with a page size equal to this limit or above.