diff --git a/Documentation/sp_BlitzFirst_Checks_by_Priority.md b/Documentation/sp_BlitzFirst_Checks_by_Priority.md index 053423541..2b7a0e25d 100644 --- a/Documentation/sp_BlitzFirst_Checks_by_Priority.md +++ b/Documentation/sp_BlitzFirst_Checks_by_Priority.md @@ -6,8 +6,8 @@ Before adding a new check, make sure to add a Github issue for it first, and hav If you want to change anything about a check - the priority, finding, URL, or ID - open a Github issue first. The relevant scripts have to be updated too. -CURRENT HIGH CHECKID: 49 -If you want to add a new check, start at 50. +CURRENT HIGH CHECKID: 50 +If you want to add a new check, start at 51. | Priority | FindingsGroup | Finding | URL | CheckID | |----------|---------------------------------|---------------------------------------|-------------------------------------------------|----------| @@ -58,4 +58,5 @@ If you want to add a new check, start at 50. | 251 | Server Info | Database Count | | 22 | | 251 | Server Info | Database Size, Total GB | | 21 | | 251 | Server Info | Memory Grant/Workspace info | | 40 | +| 251 | Server Info | Thread Time | https://www.brentozar.com/go/threadtime | 50 | | 254 | Informational | Thread Time Inaccurate | | 48 | diff --git a/sp_BlitzFirst.sql b/sp_BlitzFirst.sql index f36f5fee7..72004d33c 100644 --- a/sp_BlitzFirst.sql +++ b/sp_BlitzFirst.sql @@ -2021,6 +2021,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit, FROM sys.databases WHERE database_id > 4; + /* Server Info - Memory Grants pending - CheckID 39 */ IF (@Debug = 1) BEGIN @@ -3325,6 +3326,34 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit, OR max_session_percent >= 90); END + /* Server Info - Thread Time - CheckID 50 */ + IF (@Debug = 1) + BEGIN + RAISERROR('Running CheckID 50',10,1) WITH NOWAIT; + END + + ;WITH max_batch AS ( + SELECT MAX(SampleTime) AS SampleTime + FROM #WaitStats + ) + INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, Details, DetailsInt, URL) + SELECT TOP 1 50 AS CheckID, + 251 AS Priority, + 'Server Info' AS FindingGroup, + 'Thread Time' AS Finding, + CAST(CAST(c.[Total Thread Time (Seconds)] AS DECIMAL(18,1)) AS VARCHAR(100)) AS Details, + CAST(c.[Total Thread Time (Seconds)] AS DECIMAL(18,1)) AS DetailsInt, + 'https://www.brentozar.com/go/threadtime' AS URL + FROM max_batch b + JOIN #WaitStats wd2 ON + wd2.SampleTime =b.SampleTime + JOIN #WaitStats wd1 ON + wd1.wait_type=wd2.wait_type AND + wd2.SampleTime > wd1.SampleTime + CROSS APPLY (SELECT + CAST((wd2.thread_time_ms - wd1.thread_time_ms)/1000. AS DECIMAL(18,1)) AS [Total Thread Time (Seconds)] + ) AS c; + /* Server Info - Batch Requests per Sec - CheckID 19 */ IF (@Debug = 1) BEGIN