0% found this document useful (0 votes)
69 views

How To Check Performance of SQL Report

This document provides guidance on how to check the performance of SQL reports. It outlines how to log into databases to view report performance, compare the speeds of active reports, and examine the performance of a specific report over multiple runs. Tools covered include the ExecutionLogStorage table, setting transaction isolation levels, and using queries to retrieve metrics like data retrieval time, processing time, and rendering time. Tips are also provided for preventing locking issues, including using NOLOCK hints and adjusting transaction isolation levels.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

How To Check Performance of SQL Report

This document provides guidance on how to check the performance of SQL reports. It outlines how to log into databases to view report performance, compare the speeds of active reports, and examine the performance of a specific report over multiple runs. Tools covered include the ExecutionLogStorage table, setting transaction isolation levels, and using queries to retrieve metrics like data retrieval time, processing time, and rendering time. Tips are also provided for preventing locking issues, including using NOLOCK hints and adjusting transaction isolation levels.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

BSG ACADEMY – HOW TO CHECK

PERFORMANCE OF SQL REPORTS

SSRS / REPORT BUILDER

KATOEN NATIE | BUSINESS SUPPORT GROUP PETROCHEMICALS

1/11
TABLE OF CONTENTS

1. General information............................................................................................3
1.1. SQL management studio.....................................................................................................................3
1.2. Report databases locations.................................................................................................................3
1.2.1. Plato classic test databases........................................................................................................................................3
1.2.2. Plato classic live databases.........................................................................................................................................3

1.3. Select data source...............................................................................................................................4


2. Performance of report.........................................................................................4
2.1. Training and information.....................................................................................................................4
2.2. Performance tools...............................................................................................................................4
2.2.1. Log in to database to check performance..................................................................................................................4
2.2.2. Speed comparison of active reports...........................................................................................................................5
2.2.3. Speed of a specific report (and it separate runs).......................................................................................................5

2.3. Prevent locking....................................................................................................................................6


2.3.1. With (nolock)..............................................................................................................................................................6
2.3.2. SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;...................................................................................6

2.4. Indexes.................................................................................................................................................6
2.5. Views...................................................................................................................................................7
3. Performance of SQL query...................................................................................7
3.1. Tools available in SQL Mgmt Studio...................................................................................................7
3.1.1. Introduction................................................................................................................................................................7
3.1.2. Messages....................................................................................................................................................................7
3.1.3. Execution plan............................................................................................................................................................8

3.2. Tips & tricks for SQL reports..............................................................................................................10

2
1. GENERAL INFORMATION

1.1. SQL MANAGEMENT STUDIO

Reports and functionalities in this document requires citrix application SQL management studio version 18.

1.2. REPORT DATABASES LOCATIONS


1.2.1. PLATO CLASSIC TEST DATABASES
Server type: Database Engine
Server name: L-EMEA-SQLTPLA1
Authentication: Windows Authentication

1.2.2. PLATO CLASSIC LIVE DATABASES


Server type: Database Engine
Server name: L-EMEA-SQLPPLA1
Authentication: Windows Authentication

Server type: Database Engine


Server name: L-EMEA-SQLPPLA2
Authentication: Windows Authentication

3
1.3. SELECT DATA SOURCE

use [NAV_T_PLATO_SOFTNL]
go
Will direct you to this datasource. All queries will be executed on this data source

2. PERFORMANCE OF REPORT

2.1. TRAINING AND INFORMATION

All queries used in this section can also be found on MS Teams > BSG Academy > Report Builder – SSRS >
Tips & trics and and best practices around building queries

2.2. PERFORMANCE TOOLS


2.2.1. LOG IN TO DATABASE TO CHECK PERFORMANCE
Server name: s-be-ki-sql22\sql22

Database: SQL_O_REPORTSERVER2008R2_IIS2
Report server on production data, which might cause locking

4
Table dbo.ExecutionLogStorage contains report execution information

Open a new query

(Access request: via heat incident)

2.2.2. SPEED COMPARISON OF ACTIVE REPORTS


Use this report to evaluate which report requires (first) focus
On average all times less than 3 ms are considered as good

-- total number of executions with average time of processing, rendering and data retrieval
-- use either PLATO wild card or single report name
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT execut.[InstanceName]
,execut.[ReportID]
,cat.[Path]
,cat.[Name]
, count(execut.ExecutionId) as numOfExecutions
,avg(execut.[TimeDataRetrieval]) as AvgTimeDataRet
,avg(execut.[TimeProcessing]) as AvgTimeProcess
,avg(execut.[TimeRendering]) as AvgTimeRnd
FROM [SQL_O_REPORTSERVER2008R2_IIS2].[dbo].[ExecutionLogStorage] as execut
inner join [SQL_O_REPORTSERVER2008R2_IIS2].[dbo].[Catalog] as cat
on execut.ReportID = cat.ItemID
--where cat.Name = 'UAM - Stock Per Customer History'
where cat.[Path] like '%PLATO%'
group by execut.[InstanceName]
,execut.[ReportID]
,cat.[Path]
,cat.[Name]
order by numOfExecutions desc

This query shows a list with all reports running on SSRS with their performance parameters.

Path Folder where the evaluated report can be found


numOfExecutions Number of times the report has been executed
AvgTimeDataRet (ms) Time to find the data in the data source and to extract this data from the database
AvgTimeProcess (ms) Time to process the data
Delay(s) possibly caused by
 Many reports running simultaneously
 Reports uses data from multiple data sources
AvgTimeRnd (ms) Time to rendering the data, to get the data to the end user

5
2.2.3. SPEED OF A SPECIFIC REPORT (AND IT SEPARATE RUNS)
Use this report to evaluate 1 report
On average all times less than 3 ms are considered as good

/****** Script for SelectTopNRows command from SSMS ******/


-- Search by report name (change the report name to get info for only one report, do not remove
where filter)
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT execut.[InstanceName]
,execut.[ReportID]
,cat.[Path]
,cat.[Name]
,execut.[UserName]
,execut.[TimeDataRetrieval]
,execut.[TimeProcessing]
,execut.[TimeRendering]
,execut.[TimeStart]
,execut.[TimeEnd]
FROM [SQL_O_REPORTSERVER2008R2_IIS2].[dbo].[ExecutionLogStorage] as execut
inner join [SQL_O_REPORTSERVER2008R2_IIS2].[dbo].[Catalog] as cat
on execut.ReportID = cat.ItemID
where cat.Name = 'UAM - Stock Per Customer History'

Path Folder where the evaluated report can be found


TimeDataRetrieval (ms) Time to find the data in the data source and to extract this data from the database
= execution time of all queries in the report
TimeProcessing (ms) Time to process the data on SQL server instance on the server
= time to put the data in columns, do necessary aggregations
TimeRendering (ms) Time to rendering the data, to bring the data to the end user
= time to pass the report to the viewer/customer

2.3. PREVENT LOCKING


2.3.1. WITH (NOLOCK)
Add “with (nolock) “ after
SELECT
Column1, Column2
FROM Table with (nolock)
! Use this method when only dealing with 1 table and 1 query

2.3.2. SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;


Use the above expression at the beginning of every SQL query!
Explanation:
If new data is inserted in a table, the table gets locked to prevent that other users/services can update simultaneously.
When running the report query, there is no need to wait until all the updates are done. To read the table as it is that
moment, use the expression “SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;”.

6
2.4. INDEXES

Ideally
 a table has 5 to 7 indexed
 an index has 4 to 5 columns

-- built in procedure to list all indexes on a table plus keys


exec sp_helpindex '[dbo].[UAM -Unicontrol$PLATO Product Entry]';
go

IMPORTANT
Each index will be stored in memory buffer
(SQL Mgt > Select database > Select table > Indexes > Select index > RMB > Properties > Fragmentation Pages * 8 / 1024 is MB
used to store this index).
Adding a new index will slow down the insert and update process.
For now we will only add new indexes in test database(s). A procedure for indexes will be put in place.

2.5. VIEWS

A view takes place in the database memory

3. PERFORMANCE OF SQL QUERY

3.1. TOOLS AVAILABLE IN SQL MGMT STUDIO


3.1.1. INTRODUCTION
Add to query code:
SET STATISTICS TIME ON;
to display the number of milliseconds required to parse, compile, and execute each statement
https://docs.microsoft.com/en-us/sql/t-sql/statements/set-statistics-time-transact-sql?view=sql-server-ver15

SET STATISTICS IO ON;


to display information about the amount of disk activity generated by Transact-SQL statements
https://docs.microsoft.com/en-us/sql/t-sql/statements/set-statistics-io-transact-sql?view=sql-server-ver15

3.1.2. MESSAGES
When SET STATISTICS IO ON; tab ‘Messages’ will display information about the amount of disk activity generated by Transact-
SQL statements (https://docs.microsoft.com/en-us/sql/t-sql/statements/set-statistics-io-transact-sql?view=sql-server-ver15)

7
Table Name of the table
Scan count Number of seeks or scans started after reaching the leaf level in any direction to retrieve all the values
to construct the final dataset for the output.
Scan count is 0 if the index used is a unique index or clustered index on a primary key and you're
seeking for only one value. For example, WHERE Primary_Key_Column = <value>.
Scan count is 1 when you're searching for one value using a non-unique clustered index defined on a
non-primary key column. This process is done to check for duplicate values for the key value that
you're searching for. For example, WHERE Clustered_Index_Key_Column = <value>.
Scan count is N when N is the number of different seeks or scans started towards the left or right side
at the leaf level after locating a key value using the index key.
Logical reads Number of pages read from the data cache/index/memory
As less as possible
The higher this value is, the bigger the table to show as result
Physical reads Number of pages read from disk (not from memory which is faster)
Avoid physical reads
Read-ahead reads Number of pages placed into the cache for the query
Lob logical reads Number of pages read from the data cache. Includes text, ntext, image, varchar(max), nvarchar(max),
varbinary(max), or columnstore index pages
Lob physical reads Number of pages read from disk. Includes text, ntext, image, varchar(max), nvarchar(max),
varbinary(max), or columnstore index pages.
Lob read-ahead reads Number of pages placed into the cache for the query. Includes text, ntext, image, varchar(max),
nvarchar(max), varbinary(max), or columnstore index pages.

When SET STATISTICS TIME ON; tab ‘Messages’ will display the number of milliseconds required to parse, compile, and
execute each statement (https://docs.microsoft.com/en-us/sql/t-sql/statements/set-statistics-time-transact-sql?view=sql-
server-ver15)

CPU time ideally < 100 ms


Elapsed time time to extract data from the server and show data to the viewer

3.1.3. EXECUTION PLAN


Setup before execution of query: click on the ‘Include Actual Execution Plan’

After execution of the query the plan of execution followed is show in tab ‘Execution plan’

8
Start to read the plan from the right side

The thicker the arrow, the more difference between estimated and actual read rows in that step. Try to avoid thick lines.

Hoover over a step or click on a step to see more detailed information

9
Check for
 Number of Rows Read
o As low as possible
o As close as possible to Actual Number of Rows
 “Actual Number of Rows” and “Estimated Number of Rows” should close to each other
o Estimated rows > Actual rows: during run time this report will allocate more memory as necessary (these
resources will be block during the complete run of the report even tough they will not be used)
o Actual rows > Estimated rows: worst case, the report will run very slow
 Missing index
o Index: contains only data of selected columns
 Clustered index scan
o Is a table scan
o A search on a, to this index, sorted table
 Avoid multitraying/parallelism in the execution plan

Compare execution plans:


https://docs.microsoft.com/en-us/sql/relational-databases/performance/compare-execution-plans?view=sql-server-ver15

10
3.2. TIPS & TRICKS FOR SQL REPORTS

See BSG Academy > Report Builder - SSRS > Useful information when building SQL queries

 Check indexes
o SQL will automatically choose the fastest index available on execution
o Check for the available indexes (2.3. Prevent locking)
 Performance checkup
o Check first on Message-tab from SQL Mgmt Studio
 Avoid physical read
 Reduce logical read
o Consult execution plan in second phase
 Try to get the arrows as small as possibe

11

You might also like