Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Any ideas on why my report takes so long to run?


Any ideas on why my report takes so long to run?

Author
Message
jeichelber
jeichelber
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 124
Hello All!

I have a query that takes 9 seconds to run in SSMS and it takes 30 - 40 min. to run in SSRS.
I coded a stored procedure to run the query.
I have not done any post processing on it. (i.e. No sums, calculated fields, etc...) Just a straight detail table.

Is this a problem with my coding, SSRS or something else?

I know this is a very general question and there could be many reasons why, I just need some ideas to chase down.

Here is the actual code of the SP:


@StartDate date = '06/01/2013',
@BusUnit nvarchar (255) = 'HB,PB,HL,SL,WH'

AS
BEGIN

SET NOCOUNT ON;

SELECT shp_item.Vol, shp_item.Product, shp_item.desc2, shp_item.Price, shp_item.extension, OrderHeader.OrdNum, OrderHeader.OrdDate, OrderHeader.billtoname,
pro_duct.Description AS Desc6, shp_item.[Pro-Type],[YrAvg].F2

FROM shp_item LEFT OUTER JOIN
OrderHeader ON shp_item.[Ord-Num] = OrderHeader.OrdNum LEFT OUTER JOIN
pro_duct ON pro_duct.Product = shp_item.Product LEFT OUTER JOIN
YrAvg ON YrAvg.F1 = shp_item.Product

WHERE (shp_item.extension <> 0)
AND OrderHeader.OrdDate >= @StartDate
AND (shp_item.[Pro-Type]) collate database_default IN(SELECT Value FROM dbo.FnSplit(@BusUnit,','))
END


Any ideas would be welcome!
jeichelber
jeichelber
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 124
btw...

The function called in the SP is this:

FUNCTION [dbo].[FnSplit]
(
@List nvarchar(2000),
@SplitOn nvarchar(5)
)
RETURNS @RtnValue table
(

Id int identity(1,1),
Value nvarchar(100)
)
AS
BEGIN
While (Charindex(@SplitOn,@List)>0)
Begin
Insert Into @RtnValue (value)
Select
Value = ltrim(rtrim(Substring(@List,1,Charindex(@SplitOn,@List)-1)))
Set @List = Substring(@List,Charindex(@SplitOn,@List)+len(@SplitOn),len(@List))
End

Insert Into @RtnValue (Value)
Select Value = ltrim(rtrim(@List))
Return
END
Jack Corbett
  Jack Corbett
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11034 Visits: 14858
Are you running the report from a report server or within BIDS/SSDT?

If from a report server I'd check the ExecutionLog3 view to see if the query execution is the issue or something else.

I'd also look at what Erland Sommerskag has in his post, Slow in the Application, Fast in SSMS, to verify you aren't seeing issues related to what he discusses there.

I'd also check the execution plan because I'm not sure what the COLLATE DATABASE_DEFAULT in going to do in regard to seeks or scans on an index. If it causes the column to be converted it cause an scan where you might want a seek.

I'd also consider changing the function to be more like Jeff Moden's DelimitedSplit function which will improve that performance if you have a longer list being presented by the report.

I'd also verify that you aren't seeing "bad" parameter sniffing, where the plan for the first set of parameters passed in, is not the best plan for the next set of parameters passed in. You can check out this article (pdf) by Grant Frichey.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
jeichelber
jeichelber
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 124
This was very helpful! Thank you!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search