SSRS运行报告30秒,但在SQL Studio中只需3秒

时间:2010-08-29 19:49:07

标签: sql-server-2008 reporting-services ssrs-2008

SSRS报告从SQL 2008调用sproc,渲染它需要30秒。

如果我使用相同的参数调用同一个sproc,则需要3秒才能完成。

SQL server和SSRS在同一个框中。

我该怎么办?

4 个答案:

答案 0 :(得分:2)

对不起,这不是评论,但这还不是一个选项。

你回来了多少条记录?您是否查看过报表服务器执行表以查看数据撤销与渲染所用的时间?

如果报告返回了大量页面,则报告流式传输即... 1 of 2?还是在渲染第一个之前返回所有页面?

报告每次调用时都会占用这段时间,还是只是第一次,基本上一旦计划被缓存,它就会快速运行?可能是恭维问题。

编辑:针对您的报表服务器数据库运行此脚本。它会为您提供比您正在寻找的更多信息,但是,如果您按报告名称排序,则可以查看数据检索时间,处理时间或过程和渲染时间。这将告诉您实际拍摄时间的位置。此外,您的报表服务器将默认保存最近60天,因此如果您只想说昨天,那么取消注释where子句之间的日期。

declare 
@ReportPath varchar(200)
,@DayCount int

set @ReportPath = 'ALL'
set @DayCount = -1 * @DayCount

select 
    reverse(substring(reverse(el.ReportPath),1,charindex('/',reverse(el.ReportPath))-1)) as ReportName
    ,u.UserName as LastModBy
    ,coalesce(cast(el.parameters as varchar(max)),'') as [Parameters]
    ,round(datediff(ss,el.TimeStart, el.TimeEnd)/60,0,1) DurationMin
    ,case 
        when datediff(ss,el.TimeStart, el.TimeEnd) > 59 
            then datediff(ss,el.TimeStart, el.TimeEnd) % 60 
        else datediff(ss,el.TimeStart, el.TimeEnd)
    end as DurationSec
    ,case 
        when dt_el2.AvgDuration60Day > 59
            then cast(round(dt_el2.AvgDuration60Day / 60,0,1) as varchar(20)) + ' min ' +  cast((dt_el2.avgduration60day % 60) as varchar(20)) + ' sec' 
        else cast(dt_el2.AvgDuration60Day as varchar(20)) + ' sec'
    end as AvgDuration60Day
    ,case 
        when dt_el2.TotalDuration60Day > 59
            then cast(round(dt_el2.TotalDuration60Day / 60,0,1) as varchar(20)) + ' min ' +  cast((dt_el2.TotalDuration60Day % 60) as varchar(20)) + ' sec' 
        else cast(dt_el2.TotalDuration60Day as varchar(20)) + ' sec'
    end as TotalDuration60Day
    ,case 
        when dt_el2.MinDuration60Day > 59
            then cast(round(dt_el2.MinDuration60Day / 60,0,1) as varchar(20)) + ' min ' +  cast((dt_el2.MinDuration60Day % 60) as varchar(20)) + ' sec' 
        else cast(dt_el2.MinDuration60Day as varchar(20)) + ' sec'
    end as MinDuration60Day
    ,case 
        when dt_el2.MaxDuration60Day > 59
            then cast(round(dt_el2.MaxDuration60Day / 60,0,1) as varchar(20)) + ' min ' +  cast((dt_el2.MaxDuration60Day % 60) as varchar(20)) + ' sec' 
        else cast(dt_el2.MaxDuration60Day as varchar(20)) + ' sec'
    end as MaxDuration60Day
    ,dt_el2.Count60Day
    ,(select count(*) from executionlog2 tmp where tmp.reportpath = el.reportpath and tmp.username = el.username and tmp.reportaction = 'Render' and tmp.status = 'rsSuccess' group by tmp.ReportPath) as UserCount60Day
    ,el.Format
    ,el.UserName
    ,el.ReportAction
    ,el.Status
    ,el.Source
    ,el.[RowCount]
    ,el.ExecutionId
    ,el.TimeDataRetrieval / 1000 as DataRetrieval
    ,el.TimeProcessing / 1000 as Processing
    ,el.TimeRendering / 1000 as Rendering
    ,(el.TimeProcessing + el.TimeRendering) / 1000 as ProcessAndRender
    ,el.AdditionalInfo
    ,case
        when datediff(ss,el.TimeStart, el.TimeEnd) >= 30
            then 1
        else 2
    end as DisplayInRed

from
    ExecutionLog2 el
    join ReportServer.dbo.Catalog c  
        on c.Path = el.ReportPath
    join ReportServer.dbo.Users u  
        on u.UserId = c.ModifiedByID
    join(
            select
                reportpath
                ,sum(datediff(ss,timestart,timeend)) as TotalDuration60Day
                ,max(datediff(ss,timestart,timeend)) as MaxDuration60Day
                ,min(datediff(ss,timestart,timeend)) as MinDuration60Day
                ,avg(datediff(ss,timestart,timeend)) as AvgDuration60Day
                ,count(*) as Count60Day
                --,count(*) over(partition by username) as UserCount60Day
            from
                executionlog2
            where
                reportaction = 'Render'
                and status = 'rsSuccess'
            group by reportpath
        ) dt_el2 on el.ReportPath = dt_el2.ReportPath


where
    (@reportpath = 'ALL' or el.ReportPath = @reportpath)
    --and el.TimeStart between 
        --convert(varchar,dateadd(dd,@daycount,getdate()),112) + ' 00:00:00.000' and
        --convert(varchar,getdate(),112) + ' 23:59:59.000'
    and el.ReportPath != 'Unknown' -- exclude reports that have been deleted after executing
    and el.ReportAction = 'Render'

order by durationmin desc, DurationSec desc;

答案 1 :(得分:2)

最近,我遇到了一个非常类似的问题,一个SQL查询在SSMS上相对快速(2秒)返回大约1000行数据,但报告本身花了几分钟来呈现结果。

设置报告属性" InteractiveSize"在SSRS中强制报告对返回的数据进行分页,而不是尝试在一个页面中呈现所有内容。

这减少了将报告降低到3秒所需的时间。

~Rantscant

答案 2 :(得分:0)

你是2008 R2吗?如果是这样,请确保您应用CU3,R2非常错误。

答案 3 :(得分:0)

我注意到使用设置为调用存储过程的数据集与设置为使用文本SQL查询的数据集之间的区别,但所有文本都调用相同的SP。

EXEC custom_sp_name_here

在我看到的情况下,调用SP的测试SQL查询比将数据集设置为存储过程要好得多。

Jamie F