Sql-server – Drop and create stored procedure

performancesql server

Yesterday we have seen some production issue in my project. While many users accessing the reports in SQL Server, it got timed out and CPU went up to 100%. When we checked in the backend, some 60 sessions were open. We just decided to drop and create the stored procedure. We have dropped and recreate the stored procedure and CPU became 40% and the issue has been resolved.

Can you please let me know what might be the reason for the same. This has happened for the different stored procedure today but we have dropped and recreated the stored procedure immediately to resolve the issue.

Best Answer

The phenomenon is generally known as parameter sniffing. You got a bad execution plan due to an unusual set of parameters, and by dropping and recreating the stored proc, you've just cleared the cached execution plan for that stored procedure.

Related reading material: