-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDS_Server_Performance_Metrics.rsd
55 lines (55 loc) · 2 KB
/
DS_Server_Performance_Metrics.rsd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?xml version="1.0" encoding="utf-8"?>
<SharedDataSet xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/shareddatasetdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSet Name="DataSet1">
<Query>
<DataSourceReference>ShDS_AdventureWorks</DataSourceReference>
<CommandText>WITH CTE_Performance AS (
SELECT TOP 7
SUM(qs.total_worker_time)/(1000000) AS [CPU Time Seconds],
SUM(qs.execution_count) AS [Times Run],
qs.query_hash AS [Hash],
MIN(creation_time) AS [Creation time],
MIN(qt.text) AS [Query],
isNULL(MIN(USER_NAME(r.user_id)),'Unknow') AS [UserName]
FROM sys.dm_exec_query_stats qs CROSS apply
sys.dm_exec_sql_text(qs.sql_handle) AS qt
LEFT JOIN sys.dm_exec_requests AS r ON qs.query_hash =
r.query_hash
GROUP BY qs.query_hash
ORDER BY [CPU Time Seconds] DESC
) SELECT *, 'Query '+ CAST(ROW_NUMBER() OVER(ORDER BY([CPU Time Seconds])DESC)AS VARCHAR(3)) rnum
FROM CTE_Performance
ORDER BY [CPU Time Seconds] DESC</CommandText>
</Query>
<Fields>
<Field Name="CPU_Time_Seconds">
<DataField>CPU Time Seconds</DataField>
<rd:TypeName>System.Int64</rd:TypeName>
</Field>
<Field Name="Times_Run">
<DataField>Times Run</DataField>
<rd:TypeName>System.Int64</rd:TypeName>
</Field>
<Field Name="Hash">
<DataField>Hash</DataField>
<rd:TypeName>System.Byte[]</rd:TypeName>
</Field>
<Field Name="Creation_time">
<DataField>Creation time</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="Query">
<DataField>Query</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="UserName">
<DataField>UserName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="rnum">
<DataField>rnum</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
</SharedDataSet>