Question

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 server. 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?

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top