Optimizing Reporting Services Bob Duffy
Speaker Profile – Bob Duffy Senior SQL Consultant with Microsoft 2005-2008 Database Architect at Prodata SQL Centre Excellence, Dublin Analysis Services Maestro One of about 25 MCA for SQL Server globally SQL Server MVP, 2009+ MCM on SQL 2005 and 2008 http://blogs.prodata.ie @bob_duffy
Agenda Architecture & Internals Logging and Monitoring Parametrisation Connections DataSets Optimising Grouping and Pivoting Drill down and Navigation Top Issues
Architecture & Internals 2005=>2008+ Data Table Matrix List Chart Tablix Calcs Soft Page Layout HTML Webforms Group HTML Excel Chart Winforms Data CSV Image ROM Storage XML Step though this build slide as follows: In SSRS 2005: When data was received, each data region processed data and performed calculations. The results were stored in an intermediate format. The problem was that all data had to be processed before you could start rendering. Each rendering extension read off of Report Object Model and did pagination. Output of rendering extensions was either the Webforms control consuming HTML, or, consuming a serialized format or image renderer, the Winforms control or the Print control. In SSRS 2008: 1st change Grouping of data was pulled out of the data regions which results in consistent grouping. All data regions replaced with Tablix. Chart data region kept separate due to additional properties required for visualization. 2nd change Results of processing the data regions stored in intermediate format before calculations. Calculations can be calculated on-the-fly because raw data is always available. 3rd change Rendering object model invoked by rendering extension for a specific page. Only have to calculate expressions on requested page – iterative process based on grouping in scope on that page. Report object model abstracted into 3 module types Soft Page Layout - interactive rendering in which there is no concept of a page Data – outputs data directly Hard Page Layout – PDF and image files will always have same pagination 4th change - Offload of some rendering to client as HTML or Image Rendered at DPI of server, but higher DPI on client caused problems – now resolved Performance improved by offloading from server Hard Page Layout Image Print PDF Image
Logging and Monitoring Data Logged to “ExecutionLog” and related views Data retention is 60 days by default 2008R2+ includes much more details
Parameters
Why is the DatePicker slow? 314k for the calendar 195k per click on the calendar! No Caching
More bad news Why is the HTML very “fat” – only 31 days! Poor use of CSS and markup
Why does screen “freeze” (postback) We need to eliminate the cascade parameter
What’s wrong with multi-select? For list of stores page size grew 800KB <table cellpadding="0" cellspacing="0" style="background-color:window;"> <tr> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl00" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl00" onclick="$get('ctl31_ctl04_ctl11').control.OnSelectAllClick(this);" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl00">(Select All)</label></span></td> </tr><tr> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl01" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl01" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, $get('ctl31_ctl04_ctl11_divDropDown_ctl00'));" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl01">Total Store</label></span></td> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl02" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl02" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, $get('ctl31_ctl04_ctl11_divDropDown_ctl00'));" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl02">0 - Unknown</label></span></td> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl03" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl03" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, $get('ctl31_ctl04_ctl11_divDropDown_ctl00'));" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl03">11 - O'LEARYS HEAD OFFICE - CELEBRIDGE</label></span></td> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl04" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl04" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, $get('ctl31_ctl04_ctl11_divDropDown_ctl00'));" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl04">12 - RATHBEALE - GARRIGAN</label></span></td> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl05" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl05" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, $get('ctl31_ctl04_ctl11_divDropDown_ctl00'));" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl05">16 - ROCHFORTBRIDGE - KEN FENNELL</label></span></td> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl06" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl06" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, $get('ctl31_ctl04_ctl11_divDropDown_ctl00'));" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl06">24 - UNKNOWN-24</label></span></td> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl07" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl07" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, $get('ctl31_ctl04_ctl11_divDropDown_ctl00'));" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl07">27 - UNKNOWN-27</label></span></td> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl08" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl08" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, $get('ctl31_ctl04_ctl11_divDropDown_ctl00'));" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl08">31 - BIRR - LOUGHNANE</label></span></td> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl09" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl09" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, $get('ctl31_ctl04_ctl11_divDropDown_ctl00'));" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl09">32 - NEWCASTLE - G & L CENTRA</label></span></td> <td nowrap="nowrap"><span><input id="ctl31_ctl04_ctl11_divDropDown_ctl10" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl10" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, $get('ctl31_ctl04_ctl11_divDropDown_ctl00'));" /><label for="ctl31_ctl04_ctl11_divDropDown_ctl10">33 - GOREY - WHELAN</label></span></td>
Parameter MDX Revisited WITH MEMBER [Measures].[ParameterCaption] AS [Store].[Store].CURRENTMEMBER.MEMBER_CAPTION MEMBER [Measures].[ParameterValue] AS [Store].[Store].CURRENTMEMBER.UNIQUENAME MEMBER [Measures].[ParameterLevel] AS [Store].[Store].CURRENTMEMBER.LEVEL.ORDINAL SELECT { [Measures].[ParameterCaption], [Measures].[ParameterValue], [Measures].[ParameterLevel] } ON COLUMNS , [Store].[Store].[Store] ON ROWS FROM [CUBE] where ([Store].[Active].&[Y]) Parameter MDX Revisited What’s Not optimal here ? Cell by Cell Mode Query Scope Cache Discuss – The All Member! SELECT {} ON COLUMNS, [Store].[Store].[Store] DIMENSION PROPERTIES MEMBER_CAPTION,UNIQUE_NAME ON ROWS FROM CUBE] where ([Store].[Active].&[Y])
Parameters Summary Avoid Calendar Control Avoid Multi Select Avoid “Cell By Cell” parameters Avoid gratuitous post backs Cache where possible (no security) Seriously consider OLEDB It handles the “All Member” better
Connections Choose Between Native and OLEDB OLEDB Can be faster and return properties But has no GUI Decide if Trusted v Delegated Don’t forget Kerberos Log will spit warnings
DataSets Usually the slowest part of reports For DBEngine Stored Procs or Inline TSQL? Avoid TempDB Are we missing a star schema ? Consider Analysis Services and MDX Consider Shared / Cached DataSets Eliminate Redundant DataSets Eliminate Hidden DataSets
Grouping and Pivoting
Waste Disposal Drill Down/Through
Improving Rendering Use Matrix sparingly Avoid Footer on each page Avoid Can Grow Setting Use Rectangles as containers Avoid Chart inside Tables if possible For HTML, set the InteractiveHeight to 0 Avoid TotalPages Avoid sub-reports on large lists Images Avoid large number of images. Use built in images where possible Set AutoSize to “fit”
Using New Features to Improve Performance
New Features for Performance Use a Semantic Model Subscriptions and emailing of PDFs Shared Datasets Cache Execution Faster Servers Load Balancing
The SSRS Checklist Ensure MDX Optimised Parameters Optimised Parameters shared where possible Only pivot within MDX where makes sense Do no return large result sets Use Drill Down Actions
Top Issues in the Field Parameterisation Too much IO on query Use of Spooling to #tempdb Too Many Results Grouping or Drill Down in Report
References Reporting Services Log Viewer https://www.microsoft.com/en-us/download/confirmation.aspx?id=24774