By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,419 Members | 1,584 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,419 IT Pros & Developers. It's quick & easy.

SP timing out, can't find the cause

P: n/a
We are using SQL Server 2005. The SP in question is a fairly simple
select statement. When the developers run their unit tests it is
timing out (15 second timeout is set from their end). When I run the
SP in a query window using the exact same parameters it takes less
than a second to run. I've run profiler and turned up nothing there,
including deadlocks. The SP does show as having a duration of 15
seconds though. I've also run the blocking monitor as described on
Microsoft's site (http://support.microsoft.com/kb/271509) and I don't
see any blocking issues. I've also monitored CPU and IO access times
through the performance monitor on the server and everything looked
clear.

Is there something obvious that I should be checking? I'm at a loss
(and a bit rusty in my performance monitoring).

Thanks!
-Tom.
Nov 17 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Nov 17, 3:43*pm, "Thomas R. Hummel" <tom_hum...@hotmail.comwrote:
We are using SQL Server 2005. The SP in question is a fairly simple
select statement. When the developers run their unit tests it is
timing out (15 second timeout is set from their end). When I run the
SP in a query window using the exact same parameters it takes less
than a second to run. I've run profiler and turned up nothing there,
including deadlocks. The SP does show as having a duration of 15
seconds though. I've also run the blocking monitor as described on
Microsoft's site (http://support.microsoft.com/kb/271509) and I don't
see any blocking issues. I've also monitored CPU and IO access times
through the performance monitor on the server and everything looked
clear.

Is there something obvious that I should be checking? I'm at a loss
(and a bit rusty in my performance monitoring).
Looks like I've found the answer to my own question, at least
partially. SET arithabort OFF is coming from the application
connection and when I set that in my Management Studio I see the same
slowness. Now to find out why that's the case...

-Tom.
Nov 17 '08 #2

P: n/a
This is due most likely to having two query plans for the SP because SET
ARITHABORT is one of the options that affects plan reuse. One of the
plans is not efficient for the selected parameters. Read the following
article for more details:

http://www.microsoft.com/technet/pro...05/recomp.mspx

You can Google "parameter sniffing" for more examples. There are
different methods to solve that. You can just execute the SP using WITH
RECOMPILE to get a fresh plan. Other alternatives are to include query
hint OPTION (RECOMPILE) on the query that uses the parameters, OPTION
(OPTIMIZE FOR ...) to optimize for selected parameter value, use local
variables to assign the parameters and then use the local variables in
the query (as local variables are not sniffed). You can also use a plan
guide to apply a query hint without changing the SP.

--
Plamen Ratchev
http://www.SQLStudio.com
Nov 17 '08 #3

P: n/a
Thomas R. Hummel (to********@hotmail.com) writes:
On Nov 17, 3:43*pm, "Thomas R. Hummel" <tom_hum...@hotmail.comwrote:
>We are using SQL Server 2005. The SP in question is a fairly simple
select statement. When the developers run their unit tests it is
timing out (15 second timeout is set from their end). When I run the
SP in a query window using the exact same parameters it takes less
than a second to run. I've run profiler and turned up nothing there,
including deadlocks. The SP does show as having a duration of 15
seconds though. I've also run the blocking monitor as described on
Microsoft's site (http://support.microsoft.com/kb/271509) and I don't
see any blocking issues. I've also monitored CPU and IO access times
through the performance monitor on the server and everything looked
clear.

Is there something obvious that I should be checking? I'm at a loss
(and a bit rusty in my performance monitoring).

Looks like I've found the answer to my own question, at least
partially. SET arithabort OFF is coming from the application
connection and when I set that in my Management Studio I see the same
slowness. Now to find out why that's the case...
ARITHABORT explains why you get different plans in Mgmt Studio and the
application, but it's highly unlikely that it as such has any impact on
the query plan. It's more likely to be an issue with parameter sniffing,
that is, which value the parameters of the SP when the procedure was
called the first time. If you view the XML document of the query plan,
I think the sniffed values are present there somewhere.

ARITHABORT is on my default when you connect from Mgmt Studio, but off
by default from all client APIs.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Nov 18 '08 #4

P: n/a

See if developers use "SELECT * FROM..." in their query-s that they pass.
Make them use named fields "SELECT ID,Name, [blabla all fields just like
with * ] FROM..." and see what happens with and without "SET arithabort OFF
". Name resolving can be an issue.
Anyway arithabort handleing is good thing to do.

"Thomas R. Hummel" <to********@hotmail.comwrote in message
news:7d**********************************@e1g2000p ra.googlegroups.com...
On Nov 17, 3:43 pm, "Thomas R. Hummel" <tom_hum...@hotmail.comwrote:
We are using SQL Server 2005. The SP in question is a fairly simple
select statement. When the developers run their unit tests it is
timing out (15 second timeout is set from their end). When I run the
SP in a query window using the exact same parameters it takes less
than a second to run. I've run profiler and turned up nothing there,
including deadlocks. The SP does show as having a duration of 15
seconds though. I've also run the blocking monitor as described on
Microsoft's site (http://support.microsoft.com/kb/271509) and I don't
see any blocking issues. I've also monitored CPU and IO access times
through the performance monitor on the server and everything looked
clear.

Is there something obvious that I should be checking? I'm at a loss
(and a bit rusty in my performance monitoring).
Looks like I've found the answer to my own question, at least
partially. SET arithabort OFF is coming from the application
connection and when I set that in my Management Studio I see the same
slowness. Now to find out why that's the case...

-Tom.
Nov 19 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.