I'm at a new place and working on several issues. One item that was passed to me was this proc that used to take a few seconds is now taking well over a minute or timing out.
The data hasn't changed too drastically.
The filesReceived
table has 902,596 records.
The fileuploads
table has 629,862 records.
We run SQL2016.
Can you see if there is anything I can do to help speed this back up?
The plan: https://www.brentozar.com/pastetheplan/?id=BJc4DsywZ
OPTION (RECOMPILE)
to the end of the 2ndINSERT
statement. TheWHERE
clause has a ton of optional parameters that may be causing issues for the query optimizer. @PaulWhite has an article you may be interested in that talks about parameterization, and recompile options etc