An ERP app runs an invoice on demand and we are limited in what we can change on the DB. It seems to run for weeks in <30 mins then we have a major slowdown and it can take over 7 hours.
After any advice on improvements, changes we can make. It is running black box code via an application and we have minimal control unless we get the company in. Several tables have no indexes / poorly designed.
The execution plan + TSQL is below
Additional info: I am waiting for a change to be approved to change MAXDOP + cost threshold as I am seeing large CXPACKET waits on this system.