Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Querying a view vs tables in SSRS Dataset

Is there a best practice when it comes to using Datasets in SSRS? Should I be writing a query for the dataset that pulls directly from tables, or should I be creating a view in the source database and then querying the view via the Dataset?

I understand there are some scenarios where the view would be better (centralizing a view for use in multiple reports) and some scenarios where a query of the tables would be better (if you are not allowed access to create views in the source DB or if you utilize multiple DB data sources in one report). But are there any performance implications? Can the server still cache the results of the dataset query from SSRS in a similar fashion as it would the results in a view?

Any insight will be appreciated :-)

like image 223
rrydman Avatar asked Dec 05 '22 04:12

rrydman


1 Answers

It depends.

Using a view insulates you from data model changes - the tables can change but as long as you can get the data out as it was before, things are fine. A view is just a SQL statement, it's like running a subselect. Because of the encapsulation, there's more risk that the underlying query would be more inefficient. Using a materialized view (indexed view in SQL Server) is an option to make a query faster, but the requirements are quite limiting.

If you see the need for the same information across numerous reports - yes, use a view. Otherwise query the table directly.

Either way, do it via stored procedure...

like image 116
OMG Ponies Avatar answered Dec 24 '22 02:12

OMG Ponies