[英]Why SSRS reports works in development but not in Production
I have a SELECT statement (NOT a Stored Procedure) that I am using to create a report in SSRS (Visual Studio 2010). 我有一个SELECT语句(不是存储过程),该语句用于在SSRS(Visual Studio 2010)中创建报表。
Parameter @ClassCode is the one that causing a trouble. 参数@ClassCode是引起麻烦的参数。 But in Development it works fine, but when I deploy it to Production it renders forever.
但是在开发中,它可以正常工作,但是当我将其部署到生产环境时,它将永远渲染。
I am assuming it a Parameter Sniffing, and I read about how to fix it inside the Stored Procedure. 我假设它是参数嗅探,并且我了解了如何在存储过程中修复它。 But I dont have a SP, I am using a SELECT statement.
但是我没有SP,我正在使用SELECT语句。
What would be the workaround for SELECT statement? SELECT语句的解决方法是什么? And what is the difference between environments?
环境之间有什么区别? Production is much much more powerful.
生产功能强大得多。 My query below:
我的查询如下:
;WITH cte1
AS
(
SELECT QuoteID,
AccidentDate,
PolicyNumber,
SUM(PaidLosses) as PaidLosses
FROM tblLossesPlazaCommercialAuto
WHERE InsuredState IN (@State) AND AccidentDate BETWEEN @StartDate AND @EndDate AND TransactionDate <= @EndDate AND Coverage = 'VehicleComprehensive'
GROUP BY QuoteID,
AccidentDate,
PolicyNumber
),
cte3
AS
(
SELECT
cte1.Quoteid,
cte1.PolicyNumber,
cte1.AccidentDate,
cc.TransactionEffectiveDate,
cc.ClassCode,
CASE
WHEN ROW_NUMBER() OVER (PARTITION BY cte1.QuoteID, cte1.PolicyNumber,cc.AccidentDate ORDER BY (SELECT 0))=1 THEN cte1.PaidLosses
ELSE 0
END as PaidLosses--,
FROM cte1 inner join tblClassCodesPlazaCommercial cc
on cte1.PolicyNumber=cc.PolicyNumber
AND cte1.AccidentDate=cc.AccidentDate
AND cc.AccidentDate IS NOT NULL
/* This is the one that gives me problem */
WHERE cc.ClassCode IN (@ClassCode)
)
SELECT SUM(PaidLosses) as PaidLosses, c.YearNum, c.MonthNum
FROM cte3 RIGHT JOIN tblCalendar c ON c.YearNum = YEAR(cte3.AccidentDate) AND c.MonthNum = MONTH(cte3.AccidentDate)
WHERE c.YearNum <>2017
GROUP BY c.YearNum, c.MonthNum
ORDER BY c.YearNum, c.MonthNum
Used Tuning Advisor to see what indexes and statistics needed the workload. 使用Tuning Advisor来查看哪些索引和统计信息需要工作量。 After creating those - everything works fine.
创建这些文件后-一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.