Patent ID: 8676769

Claim:
A non-transitory computer-readable medium having computer-executable instructions stored thereon for performing a method for defragmenting indexes in a relational Microsoft SQL database, the relational database having a set of tables, in which each table has a set of indexes, and in which, for each index, a “Scan Density” parameter and a “Logical Scan Fragmentation” parameter are associated indicating fragmentation levels of the index, when the computer-executable instructions are loaded into a computer memory, the computer-executable instructions performing the following steps: a) getting a list of the set of tables from an INFORMATION_SCHEMA.TABLE SQL server system view; b) for each table of the list, getting the “Scan Density” parameter and the “Logical Scan Fragmentation” parameter associated with each of the indexes of the table by executing a “DBCC SHOWCONTIG” command; c) in case of an online index defragmentation mode, scheduled at certain times with a certain periodicity, depending on a value of the “Logical Scan Fragmentation” parameter, for each of the indexes of each of the tables, defragmenting an associated index by executing a “DBCC INDEXDEFRAG” command; and d) in case of an offline index defragmentation mode, scheduled at other times and with other periodicity, for each of the indexes of each of the tables, depending on a value of the “Scan Density” parameter, defragmenting the associated index by executing a “DBCC DBREINDEX” command.