|
|
Up |
|
|
  |
Author: axaptaaxapta Date: Jun 14, 2008 01:16
I have a simple stored procedure that I pass a where clause into. I've
noticed that on the first pass, I get a timeout in my application.
Subsequent requests are OK. Does anyone know why the timeout occurs on the
first connection? It seems like the server is 'asleep'.
Maybe my sp needs optimizing? Here is my sp:
CREATE PROCEDURE HermesArchiveSearch
@pWhereClause varchar(300)='',
@Flag int
AS
declare @rows int
declare @error int
if @Flag = 1 -- user searched on regno and/or hlscaseno
begin
exec
('SELECT applicant.apptno, applicant.surname, applicant.forename,
applicant.relcode,rtrim(ltrim(COALESCE( home.propname + '' '',...
|
| Show full article (2.64Kb) |
|
| | 7 Comments |
|
  |
Author: MLML Date: Jun 14, 2008 02:35
So, have you read the articles by Erland Sommarskog that I suggested you read
last week?
My guess is that the compilation takes longer the first time, and it exceeds
the command timeout set by the client application. It is a command timeout,
not the connection timeout, right?
ML
|
| |
|
| | no comments |
|
  |
Author: Dan GuzmanDan Guzman Date: Jun 14, 2008 08:33
To add on to Matija's response, subsequent executions may be faster because
data are cached from the first execution instead of read from disk. I
suggest you examine the execution plan for inefficiencies and perform index
and query tuning. If you need help with this, post the complete CREATE
TABLE statements and actual SQL query.
--
Hope this helps.
Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/
"axapta" gmail.com> wrote in message
news:3C7CD215-1C6B-4FE8-A83E-0C1A5EAE8AB0@microsoft.com...
>I have a simple stored procedure that I pass a where clause into. I've
>noticed that on the...
|
| Show full article (3.29Kb) |
| no comments |
|
  |
Author: John BellJohn Bell Date: Jun 14, 2008 09:42
"axapta" gmail.com> wrote in message
news:3C7CD215-1C6B-4FE8-A83E-0C1A5EAE8AB0@microsoft.com...
>I have a simple stored procedure that I pass a where clause into. I've
>noticed that on the first pass, I get a timeout in my application.
>Subsequent requests are OK. Does anyone know why the timeout occurs on the
>first connection? It seems like the server is 'asleep'.
>
> Maybe my sp needs optimizing? Here is my sp:
> CREATE PROCEDURE HermesArchiveSearch
>
> @pWhereClause varchar(300)='',
> @Flag int
>
>
> AS
>
> declare @rows int
> declare @error int
>
> if @Flag = 1 -- user searched on regno and/or hlscaseno ...
|
| Show full article (3.07Kb) |
| no comments |
|
  |
Author: Erland SommarskogErland Sommarskog Date: Jun 14, 2008 15:37
> I have a simple stored procedure that I pass a where clause into. I've
> noticed that on the first pass, I get a timeout in my application.
> Subsequent requests are OK. Does anyone know why the timeout occurs on
> the first connection? It seems like the server is 'asleep'.
As mentioned in other posts, it could be because the database is autoclose,
or because the second time data is in cache. Or a combination of them.
> Maybe my sp needs optimizing? Here is my sp:
|
| |
| no comments |
|
  |
Author: axaptaaxapta Date: Jun 14, 2008 23:44
I connect to the database on each page's onload event.
"John Bell" hotmail.com> wrote in message
news:2B58281E-8B2A-4643-BE97-84B872E97CCF@microsoft.com...
>
> "axapta" gmail.com> wrote in message
> news:3C7CD215-1C6B-4FE8-A83E-0C1A5EAE8AB0@microsoft.com...
>>I have a simple stored procedure that I pass a where clause into. I've
>>noticed that on the first pass, I get a timeout in my application.
>>Subsequent requests are OK. Does anyone know why the timeout occurs on
>>the first connection? It seems like the server is 'asleep'.
>>
>> Maybe my sp needs optimizing? Here is my sp:
>> CREATE PROCEDURE HermesArchiveSearch
>>
>> @pWhereClause varchar(300)='',
>> @Flag int
>>
>>
>> AS
>> ...
|
| Show full article (3.33Kb) |
| no comments |
|
  |
Author: Erland SommarskogErland Sommarskog Date: Jun 15, 2008 02:11
> I connect to the database on each page's onload event.
|
| |
| no comments |
|
  |
|
|
  |
Author: Eric RussellEric Russell Date: Jun 16, 2008 12:46
Use SQL Profiler to diagnose where the delay is occurring, the connection or
the stored proc call. In addition to the Duration, also compare the CPU and
Reads for successive calls. Also, add the SP:Recompile event.
Also, rather than passing in an adhoc where clause as a parameter, consider
implementing it like this:
...
where (@homeno is null or homeno=@homeno)
It may be a combination of things; I wouldn't expect a relatively simple
proc call to timeout due to compilation unless the server is very busy or you
have a very low timeout configured. If you're using SQL Server 2005, then the
following query will list how many pages of buffer cache are currently
allocated for a database object. Even a simple query can perform a lot of
data reads, and it's possible that the first call timeouts simply because the
needed data isn't cached.
|
| Show full article (4.07Kb) |
| no comments |
|
|