Strange behavior from SQL Server 2005

Hi all,

This is really a strange problem: I have one computer in my network where sql server is installed. Via another computers in the network i get the data from the sql database.

Now i created a large query but executes fast, it has multiple left joins in it but if i execute this query in sql server i get an execution time which is 0.20/0.40 sec.

if i execute the same query through a php script the execution time is 2.4/2.6
we dont have a slow network, but here comes to strange part:

if i go to my sql manager studio express and i open the tree for the current database and i open the properties (for example properties of a table) and then i reexecute the query via the php script my execution times are 0.20/0.40

how is this possible i really hope somebody can answer my question and knows a working around because the execution time really cant be over 1 or 2 seconds



Answer this question

Strange behavior from SQL Server 2005

  • KirkAtCenterstance

    The first thing you want to check is whether or not the execution plan is the same for both. You can find that out by running profiler with the showplan statistics event + binary data column. When you run the trace also get the stmtcompleted events so you can compare reads, cpu and duration.

    It may be that the first time the script was run the query, or the data it operated on was not in cache. Once the plan and data is cached execution will be much faster.



  • Strange behavior from SQL Server 2005