开发者

Is there a way to force Report Builder to use "WITH (NOLOCK)" in the queries it generates?

开发者 https://www.devze.com 2023-02-01 08:01 出处:网络
At work, users are very happy to generate their own reports using Reporting Services\' Report Builder.

At work, users are very happy to generate their own reports using Reporting Services' Report Builder.

But, alas, the queries it generates are very inefficient, and they don't use "WITH (NOLOCK)" - slowing down things for everyone.

These are reports that really do need to be run using latest data - can't be offloaded to the reporting s开发者_JAVA技巧erver. And since they query very specific, detailed data, hypercubes are of no use here.

So the question is:

Is there a way to configure Report Builder's Data Models so the queries it generates always use "WITH (NOLOCK)" when querying a table?


NOLOCK is no solution. Dirty reads are inconsistent reads. Your totals are going to be off, your reports will not balance, and you will, in general, produce garbage aggregate data. Use snapshot isolation to prevent reports from blocking updates and to prevent updates from blocking reports:

ALTER DATABASE ... SET READ_COMITTED_SNAPSHOT ON;

See Row Versioning-based Isolation Levels in the Database Engine for more details.


Create views as data source for the report, and add with (nolock) to all tables in the view's select statement.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号