I had a long list of Obsolete Updates to delete, after 3 days of run I went from 13000 updates to 9000.
I made some search and I found the following article:
https://learn.microsoft.com/en-us/troubleshoot/mem/configmgr/update-management/spdeleteupdate-slow-performance
So I included it in the script and now it is really faster.
So I recommend to include that in the script.
I attached my modified script that include the specified script and it is executed in the Run WSUS database optimization step.
Optimize-WsusServerJYD.ps1.zip