Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick query slow stored procedure...

Status
Not open for further replies.

GShort

MIS
Joined
Apr 20, 2005
Messages
70
Location
US
Hello all,

We currently have a stored procedure that is giving us fits. We use this stored procedure on a web site to give our sale staff there stats.

This stored procedure seems to run fine at first but slows done after time. We found that if we run the stored procedures code (we physicaly change the website to run from the SQL code on the site instead of the stored procedure) the stored procedure then runs fast again after changing it back.

Any Suggestions would be great.
 
What is the time frame over the slow down. Is it over the course of a single day or many days?
How often do you update your statistics?

- Paul
10qkyfp.gif

- If at first you don't succeed, find out if the loser gets anything.
 
It is usally about a day and the data is is off of live data. There are two variables of start date and end date.
 
A few things you can look at.

1. If you are experiencing the slow down by the end of the day. Run update statistics on the tables involved in the sp.

2. Check for parameter sniffing.



- Paul
10qkyfp.gif

- If at first you don't succeed, find out if the loser gets anything.
 
You can get back that credit by mentioning that WITH RECOMPILE is only one option, another would be to use something like...

OPTION (HASH JOIN)

...to force a particular join approach within the SQL statement(s) - if that is where the original problem lies :-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top