Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Any ideas on why my report takes so long to run? Expand / Collapse
Author
Message
Posted Friday, August 29, 2014 9:33 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 3, 2014 9:02 AM
Points: 21, Visits: 104
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!
Post #1608670
Posted Friday, August 29, 2014 9:44 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 3, 2014 9:02 AM
Points: 21, Visits: 104
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
Post #1608675
Posted Friday, August 29, 2014 9:57 AM This worked for the OP Answer marked as solution


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:42 PM
Points: 10,340, Visits: 13,341
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

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
Post #1608679
Posted Tuesday, September 2, 2014 4:40 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 3, 2014 9:02 AM
Points: 21, Visits: 104
This was very helpful! Thank you!
Post #1609841
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse