168168IF UPPER (@OutputType) LIKE ' TOP 10%' SET @OutputType = ' Top10' ;
169169IF @OutputType = ' Top10' SET @SinceStartup = 1 ;
170170
171+ /* Logged Message - CheckID 38 */
171172IF @LogMessage IS NOT NULL
172173 BEGIN
173174
@@ -1564,7 +1565,7 @@ BEGIN
15641565 EXECUTE sp_executesql @StringToExecute;
15651566 END ;
15661567
1567- /* Query Problems - Plan Cache Erased Recently */
1568+ /* Query Problems - Plan Cache Erased Recently - CheckID 7 */
15681569 IF DATEADD (mi, - 15 , SYSDATETIME ()) < (SELECT TOP 1 creation_time FROM sys .dm_exec_query_stats ORDER BY creation_time)
15691570 BEGIN
15701571 INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, URL , Details, HowToStopIt)
@@ -1619,7 +1620,7 @@ BEGIN
16191620 AND NOT (resource_type = N ' DATABASE' AND request_mode = N ' S' AND request_status = N ' GRANT' AND request_owner_type = N ' SHARED_TRANSACTION_WORKSPACE' ));
16201621
16211622
1622- /* Query Problems - Clients using implicit transactions */
1623+ /* Query Problems - Clients using implicit transactions - CheckID 37 */
16231624 IF @Seconds > 0
16241625 AND ( @@VERSION NOT LIKE ' Microsoft SQL Server 2005%'
16251626 AND @@VERSION NOT LIKE ' Microsoft SQL Server 2008%'
@@ -1821,7 +1822,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
18211822 OUTER APPLY sys .dm_exec_query_plan (Grants.[plan_handle]) AS QueryPlan
18221823 WHERE Grants .granted_memory_kb > ((@MemoryGrantThresholdPct/ 100 .00 )* (@MaxWorkspace* 1024 ));
18231824
1824- /* Query Problems - Memory Leak in USERSTORE_TOKENPERM Cache */
1825+ /* Query Problems - Memory Leak in USERSTORE_TOKENPERM Cache - CheckID 45 */
18251826 IF EXISTS (SELECT * FROM sys .all_columns WHERE object_id = OBJECT_ID (' sys.dm_os_memory_clerks' ) AND name = ' pages_kb' )
18261827 BEGIN
18271828 /* SQL 2012+ version */
@@ -1976,9 +1977,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
19761977 y.request_id,
19771978 y.parallelism_skew;
19781979
1979- /*
1980- CheckID 42: Queries in dm_exec_query_profiles showing signs of poor cardinality estimates
1981- */
1980+ /* Queries in dm_exec_query_profiles showing signs of poor cardinality estimates - CheckID 42 */
19821981 INSERT INTO #BlitzFirstResults
19831982 (CheckID, Priority, FindingsGroup, Finding, URL, Details, HowToStopIt, StartTime, LoginName, NTUserName, ProgramName, HostName, DatabaseID, DatabaseName, QueryText, OpenTransactionCount, QueryHash, QueryPlan)
19841983 SELECT 42 AS CheckID,
@@ -2024,9 +2023,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
20242023
20252024 SET @StringToExecute = @StringToExecute + N' ;
20262025
2027- /*
2028- CheckID 43: Queries in dm_exec_query_profiles showing signs of unbalanced parallelism
2029- */
2026+ /* Queries in dm_exec_query_profiles showing signs of unbalanced parallelism - CheckID 43 */
20302027 INSERT INTO #BlitzFirstResults
20312028 (CheckID, Priority, FindingsGroup, Finding, URL, Details, HowToStopIt, StartTime, LoginName, NTUserName, ProgramName, HostName, DatabaseID, DatabaseName, QueryText, OpenTransactionCount, QueryHash, QueryPlan)
20322029 SELECT 43 AS CheckID,
@@ -2078,7 +2075,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
20782075 END
20792076 END
20802077
2081- /* Server Performance - High CPU Utilization CheckID 24 */
2078+ /* Server Performance - High CPU Utilization - CheckID 24 */
20822079 IF @Seconds < 30
20832080 BEGIN
20842081 /* If we're waiting less than 30 seconds, run this check now rather than wait til the end.
@@ -2099,6 +2096,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
20992096 ) AS y
21002097 WHERE 100 - SystemIdle >= 50 ;
21012098
2099+ /* CPU Utilization - CheckID 23 */
21022100 IF SERVERPROPERTY (' Edition' ) <> ' SQL Azure'
21032101 WITH y
21042102 AS
@@ -2139,7 +2137,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
21392137 ORDER BY y .event_date DESC ;
21402138
21412139
2142- /* Highlight if non SQL processes are using >25% CPU */
2140+ /* Highlight if non SQL processes are using >25% CPU - CheckID 28 */
21432141 INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, Details, DetailsInt, URL )
21442142 SELECT 28 , 50 , ' Server Performance' , ' High CPU Utilization - Not SQL' , CONVERT (NVARCHAR (100 ),100 - (y .SQLUsage + y .SystemIdle )) + N ' % - Other Processes (not SQL Server) are using this much CPU. This may impact on the performance of your SQL Server instance' , 100 - (y .SQLUsage + y .SystemIdle ), ' http://www.BrentOzar.com/go/cpu'
21452143 FROM (
@@ -2342,7 +2340,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
23422340 WHERE DATEDIFF (ss, pFirst .SampleTime , pNow .SampleTime ) > 0 ;
23432341
23442342
2345- /* If we're within 10 seconds of our projected finish time, do the plan cache analysis. */
2343+ /* Query Stats - If we're within 10 seconds of our projected finish time, do the plan cache analysis. - CheckID 18 */
23462344 IF DATEDIFF (ss, @FinishSampleTime, SYSDATETIMEOFFSET ()) > 10 AND @CheckProcedureCache = 1
23472345 BEGIN
23482346
@@ -2483,7 +2481,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
24832481 FROM #QueryStats qs
24842482 INNER JOIN qsTop ON qs .ID = qsTop .ID ;
24852483
2486- /* Query Stats - CheckID 17 - Most Resource-Intensive Queries */
2484+ /* Query Stats - Most Resource-Intensive Queries - CheckID 17 */
24872485 INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, URL , Details, HowToStopIt, QueryPlan, QueryText, QueryStatsNowID, QueryStatsFirstID, PlanHandle, QueryHash)
24882486 SELECT 17 , 210 , ' Query Stats' , ' Most Resource-Intensive Queries' , ' http://www.BrentOzar.com/go/topqueries' ,
24892487 ' Query stats during the sample:' + @LineFeed +
@@ -2882,13 +2880,13 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
28822880 CROSS JOIN waits2;
28832881 END ;
28842882
2885- /* Server Performance - High CPU Utilization CheckID 24 */
2883+ /* If we're waiting 30+ seconds, run these checks at the end.
2884+ We get this data from the ring buffers, and it's only updated once per minute, so might
2885+ as well get it now - whereas if we're checking 30+ seconds, it might get updated by the
2886+ end of our sp_BlitzFirst session. */
28862887 IF @Seconds >= 30
28872888 BEGIN
2888- /* If we're waiting 30+ seconds, run this check at the end.
2889- We get this data from the ring buffers, and it's only updated once per minute, so might
2890- as well get it now - whereas if we're checking 30+ seconds, it might get updated by the
2891- end of our sp_BlitzFirst session. */
2889+ /* Server Performance - High CPU Utilization CheckID 24 */
28922890 INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, Details, DetailsInt, URL )
28932891 SELECT 24 , 50 , ' Server Performance' , ' High CPU Utilization' , CAST (100 - SystemIdle AS NVARCHAR (20 )) + N ' %. Ring buffer details: ' + CAST (record AS NVARCHAR (4000 )), 100 - SystemIdle, ' http://www.BrentOzar.com/go/cpu'
28942892 FROM (
@@ -2903,6 +2901,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
29032901 ) AS y
29042902 WHERE 100 - SystemIdle >= 50 ;
29052903
2904+ /* Server Performance - CPU Utilization CheckID 23 */
29062905 INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, Details, DetailsInt, URL )
29072906 SELECT 23 , 250 , ' Server Info' , ' CPU Utilization' , CAST (100 - SystemIdle AS NVARCHAR (20 )) + N ' %. Ring buffer details: ' + CAST (record AS NVARCHAR (4000 )), 100 - SystemIdle, ' http://www.BrentOzar.com/go/cpu'
29082907 FROM (
@@ -2975,7 +2974,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
29752974 ' We hope you found this tool useful.'
29762975 );
29772976
2978- /* Outdated sp_BlitzFirst - sp_BlitzFirst is Over 6 Months Old */
2977+ /* Outdated sp_BlitzFirst - sp_BlitzFirst is Over 6 Months Old - CheckID 27 */
29792978 IF DATEDIFF (MM, @VersionDate, SYSDATETIMEOFFSET ()) > 6
29802979 BEGIN
29812980 INSERT INTO #BlitzFirstResults
@@ -3064,8 +3063,9 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
30643063
30653064 END ;
30663065
3067- ELSE /* No sp_BlitzCache found, or it's outdated */
3066+ ELSE
30683067 BEGIN
3068+ /* No sp_BlitzCache found, or it's outdated - CheckID 36 */
30693069 INSERT INTO #BlitzFirstResults
30703070 ( CheckID ,
30713071 Priority ,
0 commit comments