How To Check Performance of SQL Report
How To Check Performance of SQL Report
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
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
2
1. GENERAL INFORMATION
Reports and functionalities in this document requires citrix application SQL management studio version 18.
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
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
Database: SQL_O_REPORTSERVER2008R2_IIS2
Report server on production data, which might cause locking
4
Table dbo.ExecutionLogStorage contains report execution information
-- 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.
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
6
2.4. INDEXES
Ideally
a table has 5 to 7 indexed
an index has 4 to 5 columns
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
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)
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.
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
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