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)
Sorry, we can’t add indexes to our users’ production servers to speed up our queries!