Index on msdb..backupset
One of my servers has a db with many filegroups and does log backups every 5 min. For this reason the msdb..backupset table is very big and SQL Monitors query
SELECT DBNAME(DBID([databasename])) AS [DBNAME(DBID([databasename]]))], MAX([backupfinishdate]) AS [MAX([backupfinishdate]])], MAX([backupstartdate]) AS [MAX([backupstartdate]])], [type] AS [[type]]] FROM msdb..backupset WITH ( NOLOCK ) WHERE DBID([databasename]) IS NOT NULL GROUP BY DBNAME(DBID([database_name])), [type]
reads ~3,500 pages per execution (CLUSTERED INDEX Scan) -> one of the TOP 10 queries (at least in the night :-)).
The following index would reduce it to ~320 reads.
CREATE INDEX idxbackupsetredgate ON dbo.backupset
(databasename, type) INCLUDE (backupfinishdate, backupstart_date)
![](https://secure.gravatar.com/avatar/b823fad2baf432b1896b181cbafea24a?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
Sorry, we can’t add indexes to our users’ production servers to speed up our queries!