olahallengren / sql-server-maintenance-solution

SQL Server Maintenance Solution
https://ola.hallengren.com
MIT License
2.91k stars 756 forks source link

Indexes don't exist, but they do #627

Open ChrisWoods1977 opened 2 years ago

ChrisWoods1977 commented 2 years ago

I am running the query below and it is throwing this error:

The following indexes in the @Indexes parameter do not exist: [msdb][dbo].[backupset].[IX_BACKUPSET_BACKUP_SET_UUID].

However, when I look at the table I see the index there. Is there some bug or problem? It works fine when I'm in a user DB, but seems to have this problem in MSDB.

EXEC _DBA_Toolbox..IndexOptimize @Databases = 'msdb', @FragmentationLow = NULL, @FragmentationMedium = 'INDEX_REORGANIZE#INDEX_REBUILD_ONLINE#INDEX_REBUILD_OFFLINE', @FragmentationHigh = 'INDEX_REBUILD_ONLINE#INDEX_REBUILD_OFFLINE', @FragmentationLevel1 = 5, @FragmentationLevel2 = 30, @MinNumberOfPages = 1000, @MaxNumberOfPages = NULL, @SortInTempdb = 'N', @MaxDOP = NULL, @FillFactor = NULL, @PadIndex = NULL, @LOBCompaction = 'Y', @UpdateStatistics = NULL, @OnlyModifiedStatistics = 'N', @StatisticsModificationLevel = NULL, @StatisticsSample = NULL, @StatisticsResample = 'N', @PartitionLevel = 'Y', @MSShippedObjects = 'N', @Indexes = '[msdb].[dbo].[backupset].[IX_BACKUPSET_BACKUP_SET_UUID]', @TimeLimit = NULL, @Delay = NULL, @WaitAtLowPriorityMaxDuration = NULL, @WaitAtLowPriorityAbortAfterWait = NULL, @Resumable = 'N', @AvailabilityGroups = NULL, @LockTimeout = 30, @LockMessageSeverity = 10, @StringDelimiter = '#', @DatabaseOrder = NULL, @DatabasesInParallel = 'N', @ExecuteAsUser = NULL, @LogToTable = 'Y', @Execute = 'Y';

hamidmira commented 2 years ago

This is not a bug.
Indeed, all the objects of the msdb system database are marked "is_ms_shipped=1". So, to process the msdb system database objects you have to assign the value 'Y' for the @MSShippedObjects parameter

EXEC _DBA_Toolbox..IndexOptimize @databases = 'msdb', ....., .....,

@MSShippedObjects = 'Y', @indexes = '[msdb].[dbo].[backupset].[IX_BACKUPSET_BACKUP_SET_UUID]', ..., ..,

A+