February 4, 2009 at 8:28 am
I have a SP that accepts 2 parms an Int and a Char(5).
EXEC@return_value = [dbo].[_Chuck]
@PlanID = 2,
@Fiscalyear = N'08/09'
SELECT'Return Value' = @return_value
When I run the SP it takes 2min 45 sec to complete
If I take the Char(5) out as a Parm and place it into the SP with a
Declare @Fiscalyear CHAR(5)
SET @Fiscalyear = '08/09'
the Sp runs in 9 seconds.
Of course I can't set it up the way as I need the char(5) to be variable.
I know i haven't posted any code, and I will if the group feels it would help
Cheers
Chuck
February 4, 2009 at 8:39 am
Chuck, run a search (on this forum) on parameter sniffing. If this is the problem, which seems likely, then the solution can be pretty straightforward.
Cheers
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
February 4, 2009 at 8:43 am
I'm on it and thanks!
Cheers
Chuck
February 4, 2009 at 8:46 am
yep same issue as the post here:http://www.sqlservercentral.com/Forums/Topic649831-8-1.aspx
i put a decent explanation and fixes there.
Lowell
February 4, 2009 at 8:48 am
Lowell (2/4/2009)
yep same issue as the post here:http://www.sqlservercentral.com/Forums/Topic649831-8-1.aspxi put a decent explanation and fixes there.
Top work Trinny, I was just about to post this one in.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
February 4, 2009 at 9:46 am
Thank you all,
I've got it down to 13 seconds as it works through about 40M rows of data.
I placed new variables inline and assigned the passed parms to them.
The DBA's are also looking into wether statistics are correctly being updated.
But I'm thrilled!
Cheers
Chuck
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply