简体   繁体   English

SSRS最佳实践 - SQL SP或SSRS表达式中的数据计算/ Aggregatopm(VS / Report Builder)

[英]SSRS Best Practice - Data Calculations/Aggregatopm in SQL SP or in SSRS Expressions (VS/Report Builder)

Should I try to do all (or as many as possible) necessary calculations for an SSRS report in SQL code (stored procedures) like summing, percentages etc. or should I do the calculations using Expressions in Report Builder/VS? 我是否应该尝试对SQL代码(存储过程)中的SSRS报告执行所有(或尽可能多的)必要计算,例如求和,百分比等,还是应该使用Report Builder / VS中的表达式进行计算?

Is there an advantage to doing one over the other? 做一个优于另一个有优势吗?

In other words, should I try to keep the data in my Datasets very granular, detailed, low level and then just use Report Builder 3.0/VS to do all the necessary calculations/aggregations? 换句话说,我应该尝试将数据集中的数据保持在非常精细,详细,低级别,然后只使用Report Builder 3.0 / VS进行所有必要的计算/聚合吗?

There is no one-size-fits-all best approach. 没有一种通用的最佳方法。 In a lot of cases, SQL will be faster at performing aggregations than SSRS. 在很多情况下,SQL执行聚合的速度比SSRS快。 SSRS will be faster at performing the kind of operations that would cause a table scan instead of an index seek when it's done in SQL. 当在SQL中完成时,SSRS将更快地执行会导致表扫描而不是索引搜索的操作。

Experience, common sense, and testing are the best guides. 经验,常识和测试是最好的指南。

Almost always you want to do your filtering and calcs on the server side. 几乎总是要在服务器端进行过滤和计算。 If you do it through a stored procedure SQL Server can optimize the query and create a well prepared, reusable, query plan. 如果通过存储过程执行此操作,SQL Server可以优化查询并创建准备充分,可重用的查询计划。 You can examine the resulting query plan and optimize it. 您可以检查生成的查询计划并对其进行优化。 None of this is possible if you create and run the code on the client side. 如果您在客户端创建并运行代码,则无法做到这一点。 How will it use indexes on the client? 它将如何在客户端上使用索引? If your report uses a lot of data your report will take a much longer time to run and your users will blame you. 如果您的报告使用大量数据,您的报告将花费更长的时间来运行,而您的用户会责怪您。 The editor in BIDS is much poorer then the one in SSMS. BIDS的编辑比SSMS的编辑差得多。 Procs can be backed up and managed through SVN of TFS. 可以通过TFS的SVN备份和管理Proc。 Unless you know for sure that it runs faster on the client (and this is very rare) learn how to create stored procedures. 除非你确定它在客户端上运行得更快(这是非常罕见的),否则学习如何创建存储过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM