.net - Stored procedure performance randomly plummets; trivial ALTER fixes it. Why? -
I have some stored procedures in SQL Server 2005 that I have seen, it will take quite a long time to complete suddenly My ASP.NET MVC app is running in the IIS 6 web form of four servers, the expected execution time is less than one second; Unexpected irregular execution time is 25-45 seconds The problem does not always look right.
However, if I change the stored procedure (even if I can not change anything in the process, except that it is possible to modify the SSMS space created by the script command), the time of completion is expected Returns at the closing time.
IIS and SQL Server are running on separate boxes, both run Windows Server 2003 R2 Enterprise Edition. SQL Server Standard Edition is the Dual Xin E5450 3GHz CPU and 4 GB RAM in all machines. SQL Server can be accessed on Gigabit Ethernet using its TCP / IP protocol (Not sure what the physical medium).
The problem exists from all web servers in the web form, when I call the process in a query window in SSMS on my development machine, the process is completed in normal time. This is strange because I was under the assumption that SSMS used the same SQL client driver in the .NET. When I point to an example of the development of the database of the development of web development, then I get a long time full of inconsistent. If my SqlCommand timeout is too short, then I will
the system. SQLlient.SqlException: Timeout expired. The expiration period has expired before the operation is completed or the server is not responding.
Question: Why should ALTER run on stored procedure, without making any changes in it, the time of completion is restored for less than one second , As expected?
Edit: To clarify this, when the process for the app is slowing down, it simultaneously the only SSMS with the same parameter that I can understand login credentials (Next time I notice the behavior, I will check with SSMS with the same password).
Resolution: I want to update this question if other people are facing this issue then this is the ultimate goal. After the clue to the answer given below, I was able to reproduce this behavior continuously. To test, I use sp_recompile
and it passes one of the sensory spreads. I then start requesting a website from my browser, which will call Sprick with Epipalical parameters. Lastly, I start requesting a website on a page which invokes sproc with specific criteria, and inspects that request is not completed due to SQL timeout on sproc invocation.
To resolve this on SQL Server 2005, I've added the option to
sign my
SELECT
. Among the all those who were weak, the "sub-in-one" pattern has been described. This pattern is definitely not ideal but there was an essential trade-off for the time limit for the project.
Parameter sniffing and reuse plans Every now and then you get a bad plan Metadata on the process Change the version to make a change so that to recompile on the next execution. Solution depends on a period of factors, you can have a bad SQL, you can get an 'unlucky' optimization, we can not provide possible information Identify the statement in a slow-moving process SQL Profiler is your friend , For example Trace Event with a period of 5000
Comments
Post a Comment