Hello. I have a massive procedure that's ran once a month which is now running 4+ hours. I need to fix this issue since. A year ago this procedure was running in 25 minutes. I was wondering if anyone can give me suggestions or direct me to a place where I can read about how to streamline this procedure. I think it's due to "Having" in the group by statement that's causing the delay but not certain... The procedure contains mutiple temp tables, updates, merge, and delete.
If someone is willing to take a look at the entire procedure I'll be more than happy to post it on here. I'm not posting the procedure on here sine this procedure is a beast and I didn't want to burden anyone too much. :)
One good thing to include on these "beast" type procedures which have many different statements is to capture some basic stats for every statement. That can be as simple as adding a "print getdate()" before each statement. If the procedure is called from another process then be sure to capture the output somewhere. for example if it is called by a job you can specify an output file. That way you can see which step(s) are taking the most time so you know where to focus your energy to correct the problem.