high performance ssrs

15
High Performance SSRS: Lessons Learned GroupBy | Bert Wagner | January 13, 2017

Upload: bert-wagner

Post on 22-Jan-2017

128 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: High Performance SSRS

High Performance SSRS:Lessons Learned

GroupBy | Bert Wagner | January 13, 2017

Page 2: High Performance SSRS

2

These are our enemies!

Page 3: High Performance SSRS

Background

● BI developer at Progressive Insurance for 6+ years● Primarily SQL 2008, 2012● Will be using StackOverflow data dump● Slide, demos, code is available on GroupBy.org and

bertwagner.com

3

Page 4: High Performance SSRS

Overview

1. SSRS Usage Data2. SELECT *3. Traffic and Specialization4. Multivalue Parameters5. Dealing with Parameter Sniffing6. Explicitly Defining Property Values7. Stored Procedure CRUD Operations8. Dynamic SQL9. Subreport Switching

denotes demo in SSRS/SQL4

Page 5: High Performance SSRS

1. SSRS Usage Data

● Important to be able to measure results○ Only way to solve “it depends” answers

● SSRS database has built in logging for analysis○ https://msdn.microsoft.com/en-us/library/ms159110.aspx

● Most useful metrics to look at when measuring performance:○ Time Data Retrieval - time getting the data for report○ Time Processing - time manipulating the data in report (sort, filter,

etc…)○ Time Rendering - time to build the report in the chose render

format (HTML, Excel, PDF, etc…)5

Page 6: High Performance SSRS

2. SELECT *● Brings back more data than you actually need● Indexes suffer/hope you like table scans● Maintainability - new columns might force changes in datasets

○ Duplicate column names might break reports○ Overtime extra columns might be brought in that aren’t needed

● Doesn’t tell future developers anything about intentions

6

Page 7: High Performance SSRS

3. Traffic and SpecializationSQL

DatabaseSSRS Server

User’s Computer

Scenario #1: No work in the query, lots of work in the report. Work includes filtering, sorting, etc…

7

Page 8: High Performance SSRS

3. Traffic and SpecializationSQL

DatabaseSSRS Server

User’s Computer

Scenario #2: Filtering, sorting in the query, reporting server just displays the page to the user

● No filtering in the dataset● No sorting in the tablix

8

Page 9: High Performance SSRS

4. Multivalue Parameters

9

● Multivalue parameters can be handled multiple different ways○ Some are more performant than others!

Page 10: High Performance SSRS

5. Dealing with Parameter Sniffing

10

● Parameter sniffing occurs when differing values in the input parameters cause a sub-optimal execution plan to be chosen

● Due to the nature of SSRS report parameters, parameter sniffing is a common problem

● Solutions:○ WITH RECOMPILE○ OPTION (RECOMPILE)○ OPTIMIZE FOR○ IF/THEN

Page 11: High Performance SSRS

6. Explicitly Defining Property Values

11

● Any report properties not explicitly defined during render have to determined by SSRS during the processing and render steps.

● Explicitly define properties like:○ Text alignment (don’t use General)

● Some properties have to do lots of calculating which hurts performance:○ AutoGrow, AutoShrink○ Image AutoSize

A full list of properties and considerations can be found here: https://technet.microsoft.com/en-us/library/bb522806(v=sql.105).aspx?f=255&MSPPError=-2147217396#Render

Page 12: High Performance SSRS

7. Stored Procedure CRUD Operations

12

● It is possible to INSERT/UPDATE/DELETE on the database from an SSRS report○ Can actually do anything that a stored procedure will allow

● There are a few things we exploit to get this to work:○ Datasets in a report always execute - even if they call a stored

procedure that inserts/updates/deletes and returns no data○ If the data source’s “single transaction” property is enabled, datasets

will execute in the order they appear

Page 13: High Performance SSRS

8. Dynamic SQL

13

● Dynamic SQL is a query that is built programmatically○ This gives us lots of flexibility in

terms of how we can display our data and build reports so they are reusable

● Dynamic SQL can run very efficiently or have terrible performance - use caution and ALWAYS test

● Dynamic SQL also leaves lots of room open for SQL injection - be sure to parameterize any user input you are building into your query

Page 14: High Performance SSRS

9. Subreport Switching

14

● Reports with lots of expressions generally take a long time to render

● If a report is using a lot of expressions, it’s sometimes possible to break them up into multiple subreports ○ The parent report decides which

subreport to run (based on efficiency)

○ This comes up a lot if you are displaying data using dynamic SQL

Page 15: High Performance SSRS

Thank you!● Session: https://GroupBy.org/go/session6● Blog: https://bertwagner.com● Email: [email protected]● Twitter: @bertwagner

15