Skip to content

Commit 00b90ab

Browse files
committed
Update Diagnostic Information Queries to 2018-07
1 parent 954cae2 commit 00b90ab

5 files changed

+149
-59
lines changed

Scripts/SQL Server 2012 Diagnostic Information Queries.sql

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
-- SQL Server 2012 Diagnostic Information Queries
33
-- Glenn Berry
4-
-- Last Modified: June 5, 2018
4+
-- Last Modified: July 5, 2018
55
-- https://www.sqlskills.com/blogs/glenn/
66
-- http://sqlserverperformance.wordpress.com/
77
-- Twitter: GlennAlanBerry
@@ -1047,7 +1047,9 @@ qs.max_elapsed_time AS [Max Elapsed Time],
10471047
qs.min_logical_reads AS [Min Logical Reads],
10481048
qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads],
10491049
qs.max_logical_reads AS [Max Logical Reads],
1050-
qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time]
1050+
qs.execution_count AS [Execution Count],
1051+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
1052+
qs.creation_time AS [Creation Time]
10511053
--,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel
10521054
FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK)
10531055
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t
@@ -1141,7 +1143,9 @@ qs.max_worker_time AS [Max Worker Time],
11411143
qs.min_elapsed_time AS [Min Elapsed Time],
11421144
qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time],
11431145
qs.max_elapsed_time AS [Max Elapsed Time],
1144-
qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time]
1146+
qs.execution_count AS [Execution Count],
1147+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
1148+
qs.creation_time AS [Creation Time]
11451149
--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel
11461150
FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK)
11471151
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t
@@ -1163,8 +1167,9 @@ qs.execution_count AS [Execution Count],
11631167
qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads],
11641168
qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads],
11651169
qs.total_worker_time/qs.execution_count AS [Avg Worker Time],
1170+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
11661171
qs.creation_time AS [Creation Time]
1167-
, qp.query_plan AS [Query Plan] -- comment out this column if copying results to Excel
1172+
--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel
11681173
FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK)
11691174
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t
11701175
CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp
@@ -1229,7 +1234,8 @@ qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads],
12291234
qs.total_worker_time AS [Total Worker Time],
12301235
qs.total_worker_time/qs.execution_count AS [Avg Worker Time],
12311236
qs.total_elapsed_time AS [Total Elapsed Time],
1232-
qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time],
1237+
qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time],
1238+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
12331239
qs.creation_time AS [Creation Time]
12341240
--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel
12351241
FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK)
@@ -1240,16 +1246,21 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE);
12401246
------
12411247

12421248

1243-
-- Queries 47 through 52 are the "Bad Man List" for stored procedures
1249+
-- Queries 50 through 55 are the "Bad Man List" for stored procedures
12441250
-- Top Cached SPs By Execution Count (Query 50) (SP Execution Counts)
1245-
SELECT TOP(100) p.name AS [SP Name], qs.execution_count,
1251+
SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count],
12461252
ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute],
1247-
qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.total_worker_time AS [TotalWorkerTime],
1248-
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1249-
qs.cached_time
1253+
qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time],
1254+
qs.total_worker_time/qs.execution_count AS [Avg Worker Time],
1255+
qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads],
1256+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
1257+
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
1258+
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
1259+
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan
12501260
FROM sys.procedures AS p WITH (NOLOCK)
12511261
INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK)
12521262
ON p.[object_id] = qs.[object_id]
1263+
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp
12531264
WHERE qs.database_id = DB_ID()
12541265
AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0
12551266
ORDER BY qs.execution_count DESC OPTION (RECOMPILE);
@@ -1264,10 +1275,14 @@ SELECT TOP(25) p.name AS [SP Name], qs.min_elapsed_time, qs.total_elapsed_time/q
12641275
qs.max_elapsed_time, qs.last_elapsed_time, qs.total_elapsed_time, qs.execution_count,
12651276
ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute],
12661277
qs.total_worker_time/qs.execution_count AS [AvgWorkerTime],
1267-
qs.total_worker_time AS [TotalWorkerTime], qs.cached_time
1278+
qs.total_worker_time AS [TotalWorkerTime],
1279+
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
1280+
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
1281+
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan
12681282
FROM sys.procedures AS p WITH (NOLOCK)
12691283
INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK)
12701284
ON p.[object_id] = qs.[object_id]
1285+
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp
12711286
WHERE qs.database_id = DB_ID()
12721287
AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0
12731288
ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE);
@@ -1282,11 +1297,15 @@ ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE);
12821297
SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime],
12831298
qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count,
12841299
ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute],
1285-
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count
1286-
AS [avg_elapsed_time], qs.cached_time
1300+
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1301+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
1302+
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
1303+
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
1304+
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan
12871305
FROM sys.procedures AS p WITH (NOLOCK)
12881306
INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK)
12891307
ON p.[object_id] = qs.[object_id]
1308+
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp
12901309
WHERE qs.database_id = DB_ID()
12911310
AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0
12921311
ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE);
@@ -1300,11 +1319,15 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE);
13001319
SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads],
13011320
qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count,
13021321
ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute],
1303-
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count
1304-
AS [avg_elapsed_time], qs.cached_time
1322+
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1323+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
1324+
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
1325+
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
1326+
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan
13051327
FROM sys.procedures AS p WITH (NOLOCK)
13061328
INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK)
13071329
ON p.[object_id] = qs.[object_id]
1330+
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp
13081331
WHERE qs.database_id = DB_ID()
13091332
AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0
13101333
ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE);
@@ -1317,11 +1340,15 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE);
13171340
-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 54) (SP Physical Reads)
13181341
SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads],
13191342
qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count,
1320-
qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count
1321-
AS [avg_elapsed_time], qs.cached_time
1343+
qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1344+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
1345+
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
1346+
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
1347+
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan
13221348
FROM sys.procedures AS p WITH (NOLOCK)
13231349
INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK)
13241350
ON p.[object_id] = qs.[object_id]
1351+
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp
13251352
WHERE qs.database_id = DB_ID()
13261353
AND qs.total_physical_reads > 0
13271354
ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOMPILE);
@@ -1337,11 +1364,15 @@ ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOM
13371364
SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites],
13381365
qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count,
13391366
ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute],
1340-
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1341-
qs.cached_time
1367+
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1368+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
1369+
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
1370+
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
1371+
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan
13421372
FROM sys.procedures AS p WITH (NOLOCK)
13431373
INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK)
13441374
ON p.[object_id] = qs.[object_id]
1375+
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp
13451376
WHERE qs.database_id = DB_ID()
13461377
AND qs.total_logical_writes > 0
13471378
AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0

Scripts/SQL Server 2014 Diagnostic Information Queries.sql

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
-- SQL Server 2014 Diagnostic Information Queries
33
-- Glenn Berry
4-
-- Last Modified: June 5, 2018
4+
-- Last Modified: July 5, 2018
55
-- https://www.sqlskills.com/blogs/glenn/
66
-- http://sqlserverperformance.wordpress.com/
77
-- Twitter: GlennAlanBerry
@@ -88,7 +88,8 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In
8888
--12.0.5557 SP2 CU8 10/16/2017
8989
--12.0.5563 SP2 CU9 12/18/2017
9090
--12.0.5571 SP2 CU10 1/16/2018
91-
-- 12.0.5579 SP2 CU11 3/19/2018
91+
-- 12.0.5579 SP2 CU11 3/19/2018
92+
--12.0.5589 SP2 CU12 6/18/2018
9293

9394

9495

@@ -1097,7 +1098,9 @@ qs.max_elapsed_time AS [Max Elapsed Time],
10971098
qs.min_logical_reads AS [Min Logical Reads],
10981099
qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads],
10991100
qs.max_logical_reads AS [Max Logical Reads],
1100-
qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time]
1101+
qs.execution_count AS [Execution Count],
1102+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
1103+
qs.creation_time AS [Creation Time]
11011104
--,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel
11021105
FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK)
11031106
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t
@@ -1191,7 +1194,9 @@ qs.max_worker_time AS [Max Worker Time],
11911194
qs.min_elapsed_time AS [Min Elapsed Time],
11921195
qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time],
11931196
qs.max_elapsed_time AS [Max Elapsed Time],
1194-
qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time]
1197+
qs.execution_count AS [Execution Count],
1198+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
1199+
qs.creation_time AS [Creation Time]
11951200
--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel
11961201
FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK)
11971202
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t
@@ -1213,8 +1218,9 @@ qs.execution_count AS [Execution Count],
12131218
qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads],
12141219
qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads],
12151220
qs.total_worker_time/qs.execution_count AS [Avg Worker Time],
1221+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
12161222
qs.creation_time AS [Creation Time]
1217-
, qp.query_plan AS [Query Plan] -- comment out this column if copying results to Excel
1223+
--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel
12181224
FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK)
12191225
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t
12201226
CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp
@@ -1295,7 +1301,8 @@ qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads],
12951301
qs.total_worker_time AS [Total Worker Time],
12961302
qs.total_worker_time/qs.execution_count AS [Avg Worker Time],
12971303
qs.total_elapsed_time AS [Total Elapsed Time],
1298-
qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time],
1304+
qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time],
1305+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
12991306
qs.creation_time AS [Creation Time]
13001307
--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel
13011308
FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK)
@@ -1306,14 +1313,15 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE);
13061313
------
13071314

13081315

1309-
-- Queries 54 through 58 are the "Bad Man List" for stored procedures
1316+
-- Queries 54 through 59 are the "Bad Man List" for stored procedures
13101317

13111318
-- Top Cached SPs By Execution Count (Query 54) (SP Execution Counts)
13121319
SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count],
13131320
ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute],
13141321
qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time],
13151322
qs.total_worker_time/qs.execution_count AS [Avg Worker Time],
13161323
qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads],
1324+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
13171325
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
13181326
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
13191327
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan
@@ -1358,6 +1366,7 @@ SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime],
13581366
qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count,
13591367
ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute],
13601368
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1369+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
13611370
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
13621371
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
13631372
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan
@@ -1378,7 +1387,8 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE);
13781387
SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads],
13791388
qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count,
13801389
ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute],
1381-
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1390+
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1391+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
13821392
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
13831393
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
13841394
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan
@@ -1399,6 +1409,7 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE);
13991409
SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads],
14001410
qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count,
14011411
qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1412+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
14021413
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
14031414
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
14041415
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan
@@ -1421,7 +1432,8 @@ ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOM
14211432
SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites],
14221433
qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count,
14231434
ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute],
1424-
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1435+
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
1436+
CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%<MissingIndexes>%' THEN 1 ELSE 0 END AS [Has Missing Index],
14251437
FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time],
14261438
FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time]
14271439
-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan

0 commit comments

Comments
 (0)