试图找出SSRS报告延迟

时间:2016-03-30 14:04:21

标签: ssrs-2012

我在SSRS中撰写报告需要很长时间才能运行。这里发生了什么:我在上午9:46和上午9:56按下查看报告按钮,我终于看到正在加载弹出窗口。报告然后在一分钟后出现。我在那里贴了一些调试显示,说明如下:

 Start: 3/30/2016 9:56:16 AM
 End: 3/30/2016 9:56:18 AM
 Elapsed: 0:01

因此,出于某种奇怪的原因,SSRS在运行报告前等待十分钟。这是一个问题,因为已部署的报告已超时。如何确定按下按钮到报告实际开始处理之间的情况?

附加:日志不会显示任何跳出来的问题。 SQL:

期限:

Select Term_Code, Term_Seq_Id, Start_Date, Long_Desc
From TERM
Where (End_Date Between '2004-05-07' AND GetDate())
Order By Term_Seq_Id Desc

RestrictionCount:

Select Count(*) as RestrictionCount from ReportUser Where LoginID = @User

节数:

Select distinct Sctn_id_code, subj_code, crse_code, sctn_code, sctn_term_code
from siscrsi
where sctn_term_code = @Term and subj_code in (@Subject) and crse_code in (@Courses) and (Pid = @Instructors or @Instructors = '<ALL>')
order by sctn_term_code, subj_code, crse_code, sctn_code

院校:

If @RestrictionCount = 0
   Select Coll_Code, Full_Name
   From College
   Order by Coll_Code
Else
   Select Distinct c.Coll_Code, c.Full_Name
   From College as c
   Inner Join sirssoctonlineforms.dbo.ReportUser as ru on ru.Coll_Code = c.Coll_Code
   Where ru.LoginID = @User
   Order by Coll_Code

主题:

Select distinct subj_code
From section_info
Where sctn_term_code = @Term and coll_code = @College and dept_code in (@Department)
order by subj_code

CoursesList:

Select Distinct Crse_Code, Subj_Code
From SISCRSI
Where Sctn_Term_Code = @Term
  and Subj_Code = @Subject 
  and ((pid = @Instructors) or (@Instructors = '<ALL>'))
Order by Crse_Code

导师:

Select 'blank' as sctn_term_code, '<ALL>' as pid, '<ALL>' as name
union all
Select distinct sctn_term_code, pid, name 
From sisinfo.dbo.SISCRSI instructor
where sctn_term_code = @Term 
  and subj_code = @Subject 
order by name

部门:

If @RestrictionCount = 0
   Select Dept_Code, Full_Name
   From Dept
   Where coll_code in (@College)
   order by Dept_Code
Else
   Select Distinct d.Dept_Code, Full_Name
   From Dept d
   Inner Join sirssoctonlineforms.dbo.ReportUser as ru on ru.Dept_code =  d.Dept_Code
   Where ru.LoginID = @User and d.Coll_Code in (@College)
   Order by Dept_Code

问题:

Select count(*) as questionCount
From Questions q
Inner Join Form_Question fq on fq.Question_Id = q.Question_Id and     q.Question_Format_Group <> 'Text'
Inner Join Response_Sets rs on rs.Form_Id = fq.Form_Id
Where rs.Sctn_Id_Code in (@SectionCodes)

NumberQuestions:

Select Top 1 dView.[Section Code], rSets.Form_ID, max(fq.Question_Order) as LastQuestion
From Denormalized_V as dView
Inner Join Response_sets as rSets on rSets.Sctn_ID_Code = dView.[Section Code]
Inner Join Form_Question as fq on fq.Form_ID = rSets.Form_ID
Where dView.[Section Code] in (@SectionCodes)
Group by [Section Code], rSets.Form_ID
Order by LastQuestion desc

InstructorPID:

If @Instructors = '<ALL>'
   Select 'NoName' as Name, 'Z000000000' as pid
Else Begin
   Select top 1 Name, pid
   From SISCRSI
   Where name = @Instructors
End

OptOutCount:

Select SectionInfo.Sctn_Id_Code as [Course Section ID], SectionInfo.Student_Cnt as [Total Students], Declined.Declined as [Total Declined]
From SECTION_INFO SectionInfo
Inner Join (
   select Sctn_Id_Code, count(Sctn_Id_Code) as [Declined]
   From declined
   Where Form_Id > 1 
     and Sctn_ID_Code in (@SectionCodes)
   Group By Sctn_Id_Code
) as Declined on SectionInfo.Sctn_Id_Code = Declined.Sctn_Id_Code

主报告查询(运行时间不到三秒):

If @nonTextQuestionCount > 0
   Select *
   From (
      Select si.Sctn_Id_Code as [Section Code],  
             si.Subj_Code as [Subject], 
             si.Crse_Code as [Course], si.Sctn_Code as [Course Section], 
             fq.Question_Order as [Question Number], 
             Case r.Instructor_PID 
                When 'ALL' Then 
                   @InstructorName 
                Else 
                   CRSI.Name 
             End as [Instructor Name], 
             rs.Set_Id as [Respondent Code], 
             Case rp.reply_ID 
                When 1 Then 
                   r.response 
                Else rp.Reply_Text 
             End as [Reply Text]
      From SECTION_INFO si 
      Inner Join Response_Sets rs on si.sctn_id_code = rs.Sctn_Id_Code 
      Inner Join Responses r on r.Set_Id = rs.Set_Id 
      Inner Join Questions q on q.Question_Id = r.Question_Id 
      Inner Join Form_Question fq on fq.Question_Id = q.Question_Id and fq.Form_Id = rs.Form_Id 
      Inner Join Forms f on f.Form_Id = fq.Form_Id 
      Inner Join Replies rp on rp.Reply_Id = r.Reply_Id 
      Left Outer Join SISINFO..SISCRSI CRSI on CRSI.PID = r.Instructor_PID 
                      and si.Sctn_Id_Code = CRSI.sctn_id_code
      Where si.Sctn_Term_Code = @Term 
        and si.Subj_Code = @Subject and si.Crse_Code in (@Courses) 
        and ((@Instructors = '<ALL>') or (r.Instructor_PID = @Instructors or r.Instructor_PID = 'ALL')) 
        and si.Sctn_Code in (@Sections) 
        and fq.Form_Id <> 1                     
   ) as q1 
   Pivot (Max([Reply Text]) For [Question Number] in 
   ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], 
    [19], [20], [21], [22], [23], [24], [25], [26], [27], [28], [29], [30], [31], [32], [33], [34], [35], 
    [36], [37], [38], [39], [40], [41], [42], [43], [44], [45], [46], [47], [48], [49], [50], [51], [52], 
    [53], [54], [55], [56], [57], [58], [59], [60], [61], [62], [63], [64])) 
   as p
   group by subject, course, [subject], [course section], [Section Code], [Instructor_Pid], 
   [respondent code],[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], 
   [16], [17], [18], [19], [20], [21], [22], [23], [24], [25], [26], [27], [28], [29], [30], [31], 
   [32], [33], [34], [35], [36], [37], [38], [39], [40], [41], [42], [43], [44], [45], [46], [47], 
   [48], [49], [50], [51], [52], [53], [54], [55], [56], [57], [58], [59], [60], [61], [62], [63], [64]
   order by [subject], [course], [course section]
Else
   Select * From
   (
   Select rSets.set_id, dView.[Course section], dView.[Subject], dView.Course, dView.[Instructor pid],
          answers.response, formQuestion.Question_Order, dView.[Section Code]
   From Denormalized_V as dView
   Inner Join response_sets as rSets on rSets.sctn_id_code = dView.[section code]
   Inner Join responses as answers on answers.set_id = rSets.set_id
   Inner Join questions as questions on questions.question_id = answers.question_id
   Inner Join form_question as formQuestion on formQuestion.question_id = questions.question_id
   where Term = @Term and 
         [Subject] = @Subject and 
         Course in (@Courses) and
         ((@Instructors = '<ALL>') or (dView.[Instructor Pid] = @Instructors or dView.[Instructor Pid] = 'ALL')) and  
         dView.[Course Section] in (@Sections) and dView.[Survey Type] <> 'SOCT'
) t
Pivot (max(response) for question_order in ([1], [2], [3], [4], [5], [6], [7], [8])) as pvt

1 个答案:

答案 0 :(得分:0)

如果在报表服务器上部署并从那里运行报表,则可能会有更好的结果。 无论如何,我认为延迟的原因是由数据集的顺序引起的。 我的意思是数据集列表上的顺序似乎表明执行的顺序。当您链接参数的数据集时,列表中的最后一个是最后执行的。这可能是您延迟的原因。 您可能必须将参数的数据集放在列表的顶部。这样做可以确保首先执行它们,而不是等待生成其他数据集。