I was wondering if you guys could help me sort out some strange problem that I recently had on SQL Server.
I have a stored procedure (allows you to call SPold ), which is quite large with a lot of calculations (maybe this cannot be done in the application, since information for about 6,000 users should be returned in one-er (I reduce this to 1000 based on Last Name) ) A stored procedure usually runs after a couple of seconds and is called once every couple of minutes.
This morning, the stored procedure suddenly lasted 4-10 times, which caused a lot of timeouts. I found that by making a copy of the procedure with a new name ( SPnew ) and executing it, I again got a quick execution sequence. This indicated that the execution plan was a problem with the original, SPold , so I decided to execute it with recompilation. This will return results faster (although not as fast as SPnew ), but subsequent calls from users to SPold were again slow. It was like the new plan was not preserved.
What I did was fix it by placing Exec SPnew in SPold , and now the calls to SPold return again.
Does anyone know what is going on here? The only thing that was updated in one night is the statistics, although I think this should affect both SPold and SPnew .
source share