The solution that Microsoft proposes to remove orphan query plans from the Data Collector was running too slowly.
After looking at the query plan, I created an index to help with the delete statements. After this, it should run quickly.
CREATE NONCLUSTERED INDEX [ix_sql_handle]
ON [snapshots].[query_stats] ([sql_handle],[statement_start_offset],[statement_end_offset],[plan_generation_num],[plan_handle],[creation_time])
Using the second index, it runs very quickly.