Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6074003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:20:02+00:00 2026-05-23T10:20:02+00:00

So I work with a largish database (30 gig) sql 2005 with a .net

  • 0

So I work with a largish database (30 gig) sql 2005 with a .net 3.5 web front end on a 10 year old system. It has new and old bits

We are getting a problem that is happening more and more frequently.

A stored proc (we’ve had 4 different ones so far) decides that it will timeout. The call is happening from the webserver and hits the 30 sec timeout and logs to our error log. The website uses a single login (I know this is wrong but it cannot be changed due to legacy code).

Just after this I run the exact same call and it takes (logged in as me) 1 sec.

The issue remains on this one stored proc until we drop and recreate it, getting loads of timeouts. Each sp call has different parameters.
As in get me all the unsigned off shifts pertaining to the current user, so current user is passed in as a parameter

The solution works but I don’t really understand why.

Our release cycle is two weeks and this error happens at anytime during it. It has happens the day after a release a week after the release and the last one was 12 days after the release.

Durign each release we SQL multi script all the stored procs/triggers/functions/views with each dropping and recreateing itself.

All I can think is that the stored proc execution plan has corrupted/gone wrong and dropping recreateing it clears this.

I am thinking of calling the sps WITH RECOMPILE option, is this a no-no?? or an acceptable way around

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:20:02+00:00Added an answer on May 23, 2026 at 10:20 am

    This sounds very much like a problem I’ve seen time and time again – where the stored procedure plan has been flushed from the plan cache and the next time the procedure is run it just so happens that the parameters passed in result in a plan that is probably great for that set of parameters but which performs awfully for other combinations.

    If you’ve ‘optional’ parameters – where NULL or a value may be passed through, and you’re using OR in the WHERE clause to cope with this then that’s usually going to lead to this sort of thing.

    WITH RECOMPILE may result in a lot of CPU going to compiling the plan each time – if the stored procedure is called a lot then this could easily have an effect on the general performance of your server – whether this os outweighed by the effect of a bad plan is another matter.

    In general, it’s better to try to rewrite the query – if you are using ORs to cope with diffferent sets of parameters then dynamic SQL (done the right way, using sp_executesql with parameters) can help a lot.

    P.S. Regarding the stored procedure working fine when you run it – I’ve seen this too – I expect that it’s down to getting a different plan generated – my suspicion has always been that running through e.g. SSMS has a slightly different set of SET options enabled than (in my instance) .Net – and the plans are cached separately in this instance. If anyone can validate that this may happen it’d be appreciated!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I work for a .NET/MSSQL shop that has trouble supporting customers running Novell, partially
I need to be notified any time a largeish asp.net mvc web application makes
work on Sql server 2000. i want to get the current server date and
work on asp.net vs 05 C#.Master page header contain the bellow code <script type=text/javascript
I work on a large ASP.NET application. Occasionally, I'll make some changes to a
I work with new Parallel.For that creates multiple threads to perform the same operation.
I work on a multi culture web project. I use Localize and Global Ressources(resx)
We work with a small development team and a system engineer who deploys the
At work, we've working on SQL Server 2008 now, and my boss seems a
At work we are currently still using JUnit 3 to run our tests. We

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.