As Fred Williams suugests, this speeds it up:
CREATE
INDEX [media_set_id] ON [dbo].[backupset] ([media_set_id])
CREATE
INDEX [restore_history_id] ON [dbo].[restorefile] ([restore_history_id])
CREATE
INDEX [restore_history_id] ON [dbo].[restorefilegroup] ([restore_history_id])