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

  • 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!

  • 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

  • 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[/url] 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.

  • This was very helpful! Thank you!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply