Stored Procedure fast in SSMS but times out in ADO.NET app

M

michael

I have stored procedure which runs in a few seconds from within Microsoft SQL
Server Management Studio. The stored procedure has a bunch of joins, all to
indexed keys.

However, if I try to use the same stored procedure from within a VS2008 VB
app, the procedure either crawls or times out. I've tried extending the time
out period, but too often the app just hangs.

I'm certain that this stored procedure runs correctly (and fast in SSMS). Is
it possible that the stored procedure is executed differently on SSMS than it
is from my app? Any other possible causes?
 
C

Cor Ligthert[MVP]

Michael,

This needs more information, it sounds now to me like: "As I go from Times
Square to the public library by metro it goes quite fast, but as I take a
plane it takes days".

Cor
 
F

Frans Bouma [C# MVP]

michael said:
I have stored procedure which runs in a few seconds from within Microsoft SQL
Server Management Studio. The stored procedure has a bunch of joins, all to
indexed keys.

However, if I try to use the same stored procedure from within a VS2008 VB
app, the procedure either crawls or times out. I've tried extending the time
out period, but too often the app just hangs.

I'm certain that this stored procedure runs correctly (and fast in SSMS). Is
it possible that the stored procedure is executed differently on SSMS than it
is from my app? Any other possible causes?

without your code which executes the proc, it's impossible to check.

Also, does the proc return values? If the proc does return a lot of
data, and for example image/text/varchar(max) kind of columns, the total
amount of data to consume on the client is HUGE, which will take a lot
of time. SSMS cuts off these resultsets in a more efficient matter.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
M

michael

Who knew!!

You got this one correct.

Fixed the problem with local variables assigned to the parameters passed to
the StoredProcedure.

Thanks!!
 
S

sloan

Yeah.

My fixes have included...sometimes using the "local variable" trick.
And sometimes using the OPTION RECOMPILE.

I had to do some testing to figure out which one worked best for a
particular usp (user stored procedure).

........

And I'm thankful to the first person who told me about it.


Ask for a raise now! You "da man" with this nugget.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top