How To: Exclude databases from index maintenance


You can exclude a database from all index maintenance in any of three ways:

  • Database level settings: In the Minion.IndexSettingsDB table, insert or update the row for that database and set the Exclude column = 1. 
  • Run time parameter: In the appropriate reindex job(s), use the @Exclude parameter of the Minion.IndexMaintMaster procedure. This parameter accepts a column-delimited list of database names, and/or LIKE expressions. (E.g., @Exclude = ‘DB1, DB3, Archive%’.)
  • Regex exclusion (advanced): In the Minion.DBMaintRegexLookup table, insert a row with Action=’Exclude’ and the appropriate regular expression to encompass the proper set of database names.

Database level settings: To exclude [YourDatabase] from the Minion.IndexSettingsDB table, update the existing row, or insert a row:

INSERT INTO [Minion].[IndexSettingsDB]
           ( DBName
           , Exclude
           )
     VALUES
           ('YourDatabase'  -- DBName
           , 1    -- Exclude
           );



Run time parameter: To exclude [YourDatabase] from just one job running Minion.IndexMaintMaster, set the @Exclude parameter = ‘YourDatabase’.  

If you wanted to exclude all databases that begin with the string "Archive", set @Exclude to "Archive%".

Regex exclusion: This advanced option is controlled by regular expressions in a table, to exclude databases. This is most commonly used in rolling database scenarios, where you have archive or test databases with rolling names.


For example, to exclude all databases beginning with the word "Archive", and ending in a number (e.g. Archive2, Archive3, Archive201410), insert the following row:

INSERT  INTO [Minion].[DBMaintRegexLookup]
   ( [Action]
    , MaintType
    , Regex )
VALUES  
( 'EXCLUDE'   -- Action. EXCLUDE or INCLUDE
     , 'ALL'    -- MaintType. ALL or REINDEX
     , '^Archive\d' );  -- Regex expression


NOTE: The use of the regular expressions exclude feature is not supported in SQL Server 2005.