Why does output of a request becomes slow at first call

  • Hi,

    I am using webservices (ASP.Net) which communicates with sql server.

    Its taking 4 to 5 seconds to return a record set from database for very first time. After that it will take very less time to execute...

    I checked with reads and duration of tht particular stored procedure..

    Its taking very less time and reads...

    Then why the records returning getting slower....?

    Is it because establishing connection of webservice with sql server ???

    or is there any other reason.....???

    Plz help me.....

  • It is probably because the batch needs to be compiled and the data it needs might not be in memory. Once you have run it once, the chances are high that the execution plan can be re-used and at least some of the data required will already be in memory from the last execution.

    If you post more details and perhaps some example code, we might be able to give more advice.

    The above is a guess based on the usual reasons why subsequent executions tend to be faster than the first.

    Paul

  • Hi

    This can also depend on the .Net web-service. .Net uses on demand loading of related assemblies. Since you need at least System.Data.dll and maybe some other middle tier layer DLLs for your first data access they have to be loaded at this time.

    To exclude one of the possible reasons for the wait time enable TIME statistics within your first request statement and handle the client messages returned by your SqlConnection. This will show you if the time depends on your server request or on client side.

    Greets

    Flo

  • Good point Flo!

  • Thank u guys.....:)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply