I have a strange problem in the reproductive environment.
I have a website which is a web API hosted on another API.
Typically a specific post will take it in one second to request, but after 5 minutes of inactivity, the same post request will take 10-30 seconds. (According to Google Chrome Network tab)
The first request is not in the list of requested post request requests.
The request Ajax is used.
I have run SQL Profiler to see that the database queries were running slow, but they are all doing well, and it seems that the POST request is only returning late.Do you have any idea why this is happening?
A very likely reason is compiled at the database level for the first time when you query a query with most database engines SQL should be compiled and SQL should be compiled and an execution plan should be developed. It is then cached for a while when it is no longer cached, then it needs to be done again, now your SQL string, it takes more time to compile it.
The solution is to use a stored procedure once it is run, it remains compiled and the execution plan is always available.
Comments
Post a Comment