Skip to content

Commit 628c147

Browse files
committed
#3660 sp_BlitzFirst thread time
Adds units of measure, updates release dates and versions for 2025-07-04 release. Closes #3660.
1 parent 222e072 commit 628c147

13 files changed

+479
-261
lines changed

Install-All-Scripts.sql

Lines changed: 323 additions & 210 deletions
Large diffs are not rendered by default.

Install-Azure.sql

Lines changed: 111 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ AS
3737
SET NOCOUNT ON;
3838
SET STATISTICS XML OFF;
3939

40-
SELECT @Version = '8.24', @VersionDate = '20250407';
40+
SELECT @Version = '8.25', @VersionDate = '20250704';
4141

4242
IF(@VersionCheckMode = 1)
4343
BEGIN
@@ -1147,6 +1147,7 @@ ALTER PROCEDURE dbo.sp_BlitzCache
11471147
@DurationFilter DECIMAL(38,4) = NULL ,
11481148
@HideSummary BIT = 0 ,
11491149
@IgnoreSystemDBs BIT = 1 ,
1150+
@IgnoreReadableReplicaDBs BIT = 1 ,
11501151
@OnlyQueryHashes VARCHAR(MAX) = NULL ,
11511152
@IgnoreQueryHashes VARCHAR(MAX) = NULL ,
11521153
@OnlySqlHandles VARCHAR(MAX) = NULL ,
@@ -1173,7 +1174,7 @@ SET NOCOUNT ON;
11731174
SET STATISTICS XML OFF;
11741175
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
11751176

1176-
SELECT @Version = '8.24', @VersionDate = '20250407';
1177+
SELECT @Version = '8.25', @VersionDate = '20250704';
11771178
SET @OutputType = UPPER(@OutputType);
11781179

11791180
IF(@VersionCheckMode = 1)
@@ -2296,7 +2297,7 @@ CREATE TABLE #plan_usage
22962297
);
22972298

22982299

2299-
IF EXISTS (SELECT * FROM sys.all_objects o WHERE o.name = 'dm_hadr_database_replica_states')
2300+
IF @IgnoreReadableReplicaDBs = 1 AND EXISTS (SELECT * FROM sys.all_objects o WHERE o.name = 'dm_hadr_database_replica_states')
23002301
BEGIN
23012302
RAISERROR('Checking for Read intent databases to exclude',0,0) WITH NOWAIT;
23022303

@@ -2715,7 +2716,7 @@ IF @VersionShowsAirQuoteActualPlans = 1
27152716

27162717
SET @body += N' WHERE 1 = 1 ' + @nl ;
27172718

2718-
IF EXISTS (SELECT * FROM sys.all_objects o WHERE o.name = 'dm_hadr_database_replica_states')
2719+
IF @IgnoreReadableReplicaDBs = 1 AND EXISTS (SELECT * FROM sys.all_objects o WHERE o.name = 'dm_hadr_database_replica_states')
27192720
BEGIN
27202721
RAISERROR(N'Ignoring readable secondaries databases by default', 0, 1) WITH NOWAIT;
27212722
SET @body += N' AND CAST(xpa.value AS INT) NOT IN (SELECT database_id FROM #ReadableDBs)' + @nl ;
@@ -8557,7 +8558,7 @@ SET NOCOUNT ON;
85578558
SET STATISTICS XML OFF;
85588559
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
85598560

8560-
SELECT @Version = '8.24', @VersionDate = '20250407';
8561+
SELECT @Version = '8.25', @VersionDate = '20250704';
85618562

85628563
IF(@VersionCheckMode = 1)
85638564
BEGIN
@@ -10148,22 +10149,22 @@ BEGIN
1014810149
'Maintenance Tasks Running' AS FindingGroup,
1014910150
'Restore Running' AS Finding,
1015010151
'https://www.brentozar.com/askbrent/backups/' AS URL,
10151-
'Restore of ' + DB_NAME(db.resource_database_id) + ' database (' + (SELECT CAST(CAST(SUM(size * 8.0 / 1024 / 1024) AS BIGINT) AS NVARCHAR) FROM #MasterFiles WHERE database_id = db.resource_database_id) + 'GB) is ' + CAST(r.percent_complete AS NVARCHAR(100)) + '% complete, has been running since ' + CAST(r.start_time AS NVARCHAR(100)) + '. ' AS Details,
10152+
'Restore of ' + COALESCE(DB_NAME(db.resource_database_id), 'Unknown Database') + ' database (' + COALESCE((SELECT CAST(CAST(SUM(size * 8.0 / 1024 / 1024) AS BIGINT) AS NVARCHAR) FROM #MasterFiles WHERE database_id = db.resource_database_id), 'Unknown') + 'GB) is ' + CAST(r.percent_complete AS NVARCHAR(100)) + '% complete, has been running since ' + CAST(r.start_time AS NVARCHAR(100)) + '. ' AS Details,
1015210153
'KILL ' + CAST(r.session_id AS NVARCHAR(100)) + ';' AS HowToStopIt,
1015310154
pl.query_plan AS QueryPlan,
1015410155
r.start_time AS StartTime,
1015510156
s.login_name AS LoginName,
1015610157
s.nt_user_name AS NTUserName,
1015710158
s.[program_name] AS ProgramName,
1015810159
s.[host_name] AS HostName,
10159-
db.[resource_database_id] AS DatabaseID,
10160-
DB_NAME(db.resource_database_id) AS DatabaseName,
10160+
COALESCE(db.[resource_database_id],0) AS DatabaseID,
10161+
COALESCE(DB_NAME(db.resource_database_id), 'Unknown') AS DatabaseName,
1016110162
0 AS OpenTransactionCount,
1016210163
r.query_hash
1016310164
FROM sys.dm_exec_requests r
1016410165
INNER JOIN sys.dm_exec_connections c ON r.session_id = c.session_id
1016510166
INNER JOIN sys.dm_exec_sessions s ON r.session_id = s.session_id
10166-
INNER JOIN (
10167+
LEFT OUTER JOIN (
1016710168
SELECT DISTINCT request_session_id, resource_database_id
1016810169
FROM sys.dm_tran_locks
1016910170
WHERE resource_type = N'DATABASE'
@@ -10531,6 +10532,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
1053110532
FROM sys.databases
1053210533
WHERE database_id > 4;
1053310534

10535+
1053410536
/* Server Info - Memory Grants pending - CheckID 39 */
1053510537
IF (@Debug = 1)
1053610538
BEGIN
@@ -11590,6 +11592,28 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
1159011592
END;
1159111593

1159211594

11595+
/* Query Problems - Deadlocks - CheckID 51 */
11596+
IF (@Debug = 1)
11597+
BEGIN
11598+
RAISERROR('Running CheckID 51',10,1) WITH NOWAIT;
11599+
END
11600+
11601+
INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, URL, Details, HowToStopIt)
11602+
SELECT 51 AS CheckID,
11603+
100 AS Priority,
11604+
'Query Problems' AS FindingGroup,
11605+
'Deadlocks' AS Finding,
11606+
' https://www.brentozar.com/go/deadlocks' AS URL,
11607+
'Number of deadlocks during the sample: ' + CAST(ps.value_delta AS NVARCHAR(20)) + @LineFeed
11608+
+ 'Determined by sampling Perfmon counter ' + ps.object_name + ' - ' + ps.counter_name + @LineFeed AS Details,
11609+
'Check sp_BlitzLock to find which indexes and queries to tune.' AS HowToStopIt
11610+
FROM #PerfmonStats ps
11611+
WHERE ps.Pass = 2
11612+
AND counter_name = 'Number of Deadlocks/sec'
11613+
AND instance_name LIKE '_Total%'
11614+
AND value_delta > 0;
11615+
11616+
1159311617
/* SQL Server Internal Maintenance - Log File Growing - CheckID 13 */
1159411618
IF (@Debug = 1)
1159511619
BEGIN
@@ -11835,6 +11859,53 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
1183511859
OR max_session_percent >= 90);
1183611860
END
1183711861

11862+
/* Server Info - Thread Time - CheckID 50 */
11863+
IF (@Debug = 1)
11864+
BEGIN
11865+
RAISERROR('Running CheckID 50',10,1) WITH NOWAIT;
11866+
END
11867+
11868+
;WITH max_batch AS (
11869+
SELECT MAX(SampleTime) AS SampleTime
11870+
FROM #WaitStats
11871+
)
11872+
INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, Details, DetailsInt, URL)
11873+
SELECT TOP 1
11874+
50 AS CheckID,
11875+
251 AS Priority,
11876+
'Server Info' AS FindingGroup,
11877+
'Thread Time' AS Finding,
11878+
LTRIM(
11879+
CASE
11880+
WHEN c.[TotalThreadTimeSeconds] >= 86400 THEN
11881+
CAST(c.[TotalThreadTimeSeconds] / 86400 AS VARCHAR) + 'd '
11882+
ELSE ''
11883+
END +
11884+
CASE
11885+
WHEN c.[TotalThreadTimeSeconds] % 86400 >= 3600 THEN
11886+
CAST((c.[TotalThreadTimeSeconds] % 86400) / 3600 AS VARCHAR) + 'h '
11887+
ELSE ''
11888+
END +
11889+
CASE
11890+
WHEN c.[TotalThreadTimeSeconds] % 3600 >= 60 THEN
11891+
CAST((c.[TotalThreadTimeSeconds] % 3600) / 60 AS VARCHAR) + 'm '
11892+
ELSE ''
11893+
END +
11894+
CASE
11895+
WHEN c.[TotalThreadTimeSeconds] % 60 > 0 OR c.[TotalThreadTimeSeconds] = 0 THEN
11896+
CAST(c.[TotalThreadTimeSeconds] % 60 AS VARCHAR) + 's'
11897+
ELSE ''
11898+
END
11899+
) AS Details,
11900+
CAST(c.[TotalThreadTimeSeconds] AS DECIMAL(18,1)) AS DetailsInt,
11901+
'https://www.brentozar.com/go/threadtime' AS URL
11902+
FROM max_batch b
11903+
JOIN #WaitStats wd2 ON wd2.SampleTime = b.SampleTime
11904+
JOIN #WaitStats wd1 ON wd1.wait_type = wd2.wait_type AND wd2.SampleTime > wd1.SampleTime
11905+
CROSS APPLY (
11906+
SELECT CAST((wd2.thread_time_ms - wd1.thread_time_ms) / 1000 AS INT) AS TotalThreadTimeSeconds
11907+
) AS c;
11908+
1183811909
/* Server Info - Batch Requests per Sec - CheckID 19 */
1183911910
IF (@Debug = 1)
1184011911
BEGIN
@@ -13164,13 +13235,13 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
1316413235
wd1.wait_type,
1316513236
COALESCE(wcat.WaitCategory, 'Other') AS wait_category,
1316613237
CAST(c.[Wait Time (Seconds)] / 60. / 60. AS DECIMAL(18,1)) AS [Wait Time (Hours)],
13167-
CAST((wd2.wait_time_ms - wd1.wait_time_ms) / 1000.0 / cores.cpu_count / DATEDIFF(ss, wd1.SampleTime, wd2.SampleTime) AS DECIMAL(18,1)) AS [Per Core Per Hour],
13168-
(wd2.waiting_tasks_count - wd1.waiting_tasks_count) AS [Number of Waits],
1316913238
CASE WHEN (wd2.waiting_tasks_count - wd1.waiting_tasks_count) > 0
1317013239
THEN
1317113240
CAST((wd2.wait_time_ms-wd1.wait_time_ms)/
1317213241
(1.0*(wd2.waiting_tasks_count - wd1.waiting_tasks_count)) AS NUMERIC(12,1))
13173-
ELSE 0 END AS [Avg ms Per Wait]
13242+
ELSE 0 END AS [Avg ms Per Wait],
13243+
CAST((wd2.wait_time_ms - wd1.wait_time_ms) / 1000.0 / cores.cpu_count / DATEDIFF(ss, wd1.SampleTime, wd2.SampleTime) AS DECIMAL(18,1)) AS [Per Core Per Hour],
13244+
(wd2.waiting_tasks_count - wd1.waiting_tasks_count) AS [Number of Waits]
1317413245
FROM max_batch b
1317513246
JOIN #WaitStats wd2 ON
1317613247
wd2.SampleTime =b.SampleTime
@@ -13309,17 +13380,17 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
1330913380
wd1.wait_type,
1331013381
COALESCE(wcat.WaitCategory, 'Other') AS wait_category,
1331113382
CAST(c.[Wait Time (Seconds)] / 60. / 60. AS DECIMAL(18,1)) AS [Wait Time (Hours)],
13383+
CASE WHEN (wd2.waiting_tasks_count - wd1.waiting_tasks_count) > 0
13384+
THEN
13385+
CAST((wd2.wait_time_ms-wd1.wait_time_ms)/
13386+
(1.0*(wd2.waiting_tasks_count - wd1.waiting_tasks_count)) AS NUMERIC(12,1))
13387+
ELSE 0 END AS [Avg ms Per Wait],
1331213388
CAST((wd2.wait_time_ms - wd1.wait_time_ms) / 1000.0 / cores.cpu_count / DATEDIFF(ss, wd1.SampleTime, wd2.SampleTime) AS DECIMAL(18,1)) AS [Per Core Per Hour],
1331313389
CAST(c.[Signal Wait Time (Seconds)] / 60.0 / 60 AS DECIMAL(18,1)) AS [Signal Wait Time (Hours)],
1331413390
CASE WHEN c.[Wait Time (Seconds)] > 0
1331513391
THEN CAST(100.*(c.[Signal Wait Time (Seconds)]/c.[Wait Time (Seconds)]) AS NUMERIC(4,1))
1331613392
ELSE 0 END AS [Percent Signal Waits],
1331713393
(wd2.waiting_tasks_count - wd1.waiting_tasks_count) AS [Number of Waits],
13318-
CASE WHEN (wd2.waiting_tasks_count - wd1.waiting_tasks_count) > 0
13319-
THEN
13320-
CAST((wd2.wait_time_ms-wd1.wait_time_ms)/
13321-
(1.0*(wd2.waiting_tasks_count - wd1.waiting_tasks_count)) AS NUMERIC(12,1))
13322-
ELSE 0 END AS [Avg ms Per Wait],
1332313394
N'https://www.sqlskills.com/help/waits/' + LOWER(wd1.wait_type) + '/' AS URL
1332413395
FROM max_batch b
1332513396
JOIN #WaitStats wd2 ON
@@ -13353,17 +13424,17 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
1335313424
wd1.wait_type,
1335413425
COALESCE(wcat.WaitCategory, 'Other') AS wait_category,
1335513426
c.[Wait Time (Seconds)],
13427+
CASE WHEN (wd2.waiting_tasks_count - wd1.waiting_tasks_count) > 0
13428+
THEN
13429+
CAST((wd2.wait_time_ms-wd1.wait_time_ms)/
13430+
(1.0*(wd2.waiting_tasks_count - wd1.waiting_tasks_count)) AS NUMERIC(12,1))
13431+
ELSE 0 END AS [Avg ms Per Wait],
1335613432
CAST((CAST(wd2.wait_time_ms - wd1.wait_time_ms AS MONEY)) / 1000.0 / cores.cpu_count / DATEDIFF(ss, wd1.SampleTime, wd2.SampleTime) AS DECIMAL(18,1)) AS [Per Core Per Second],
1335713433
c.[Signal Wait Time (Seconds)],
1335813434
CASE WHEN c.[Wait Time (Seconds)] > 0
1335913435
THEN CAST(100.*(c.[Signal Wait Time (Seconds)]/c.[Wait Time (Seconds)]) AS NUMERIC(4,1))
1336013436
ELSE 0 END AS [Percent Signal Waits],
1336113437
(wd2.waiting_tasks_count - wd1.waiting_tasks_count) AS [Number of Waits],
13362-
CASE WHEN (wd2.waiting_tasks_count - wd1.waiting_tasks_count) > 0
13363-
THEN
13364-
CAST((wd2.wait_time_ms-wd1.wait_time_ms)/
13365-
(1.0*(wd2.waiting_tasks_count - wd1.waiting_tasks_count)) AS NUMERIC(12,1))
13366-
ELSE 0 END AS [Avg ms Per Wait],
1336713438
N'https://www.sqlskills.com/help/waits/' + LOWER(wd1.wait_type) + '/' AS URL
1336813439
FROM max_batch b
1336913440
JOIN #WaitStats wd2 ON
@@ -13567,7 +13638,7 @@ SET NOCOUNT ON;
1356713638
SET STATISTICS XML OFF;
1356813639
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
1356913640

13570-
SELECT @Version = '8.24', @VersionDate = '20250407';
13641+
SELECT @Version = '8.25', @VersionDate = '20250704';
1357113642
SET @OutputType = UPPER(@OutputType);
1357213643

1357313644
IF(@VersionCheckMode = 1)
@@ -20357,7 +20428,7 @@ BEGIN
2035720428
SET XACT_ABORT OFF;
2035820429
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
2035920430

20360-
SELECT @Version = '8.24', @VersionDate = '20250407';
20431+
SELECT @Version = '8.25', @VersionDate = '20250704';
2036120432

2036220433
IF @VersionCheckMode = 1
2036320434
BEGIN
@@ -21570,7 +21641,7 @@ BEGIN
2157021641
END;
2157121642

2157221643
/* If table target */
21573-
IF @TargetSessionType = 'table'
21644+
IF LOWER(@TargetSessionType) = N'table'
2157421645
BEGIN
2157521646
SET @d = CONVERT(varchar(40), GETDATE(), 109);
2157621647
RAISERROR('Inserting to #deadlock_data from table source %s', 0, 1, @d) WITH NOWAIT;
@@ -21588,9 +21659,19 @@ BEGIN
2158821659
SELECT TOP (1)
2158921660
@xe = xe.e.exist(''.''),
2159021661
@xd = xd.e.exist(''.'')
21591-
FROM [master].[dbo].[bpr] AS x
21592-
OUTER APPLY x.[bpr].nodes(''/event'') AS xe(e)
21593-
OUTER APPLY x.[bpr].nodes(''/deadlock'') AS xd(e)
21662+
FROM ' +
21663+
QUOTENAME(@TargetDatabaseName) +
21664+
N'.' +
21665+
QUOTENAME(@TargetSchemaName) +
21666+
N'.' +
21667+
QUOTENAME(@TargetTableName) +
21668+
N' AS x
21669+
OUTER APPLY x.' +
21670+
QUOTENAME(@TargetColumnName) +
21671+
N'.nodes(''/event'') AS xe(e)
21672+
OUTER APPLY x.' +
21673+
QUOTENAME(@TargetColumnName) +
21674+
N'.nodes(''/deadlock'') AS xd(e)
2159421675
OPTION(RECOMPILE);
2159521676
';
2159621677

@@ -21727,6 +21808,7 @@ BEGIN
2172721808
LEFT JOIN #t AS t
2172821809
ON 1 = 1
2172921810
WHERE @xe = 1
21811+
OR LOWER(@TargetSessionType) <> N'table'
2173021812

2173121813
UNION ALL
2173221814

@@ -24890,7 +24972,7 @@ BEGIN
2489024972
SET STATISTICS XML OFF;
2489124973
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
2489224974

24893-
SELECT @Version = '8.24', @VersionDate = '20250407';
24975+
SELECT @Version = '8.25', @VersionDate = '20250704';
2489424976

2489524977
IF(@VersionCheckMode = 1)
2489624978
BEGIN

SqlServerVersions.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ INSERT INTO dbo.SqlServerVersions
4242
(MajorVersionNumber, MinorVersionNumber, Branch, [Url], ReleaseDate, MainstreamSupportEndDate, ExtendedSupportEndDate, MajorVersionName, MinorVersionName)
4343
VALUES
4444
/*2022*/
45+
(17, 800, 'CTP 2.1', 'https://info.microsoft.com/ww-landing-sql-server-2025.html', '2025-06-16', '2025-12-31', '2025-12-31', 'SQL Server 2025', 'Preview CTP 2.1'),
46+
(17, 700, 'CTP 2.0', 'https://info.microsoft.com/ww-landing-sql-server-2025.html', '2025-05-19', '2025-12-31', '2025-12-31', 'SQL Server 2025', 'Preview CTP 2.0'),
47+
/*2022*/
48+
(16, 4195, 'CU19', 'https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate19', '2025-05-19', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 19'),
4549
(16, 4185, 'CU18', 'https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate18', '2025-03-13', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 18'),
4650
(16, 4175, 'CU17', 'https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate17', '2025-01-16', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 17'),
4751
(16, 4165, 'CU16', 'https://support.microsoft.com/en-us/help/5048033', '2024-11-14', '2028-01-11', '2033-01-11', 'SQL Server 2022', 'Cumulative Update 16'),

sp_Blitz.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ AS
3838
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
3939

4040

41-
SELECT @Version = '8.24', @VersionDate = '20250407';
41+
SELECT @Version = '8.25', @VersionDate = '20250704';
4242
SET @OutputType = UPPER(@OutputType);
4343

4444
IF(@VersionCheckMode = 1)

sp_BlitzAnalysis.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ AS
3737
SET NOCOUNT ON;
3838
SET STATISTICS XML OFF;
3939

40-
SELECT @Version = '8.24', @VersionDate = '20250407';
40+
SELECT @Version = '8.25', @VersionDate = '20250704';
4141

4242
IF(@VersionCheckMode = 1)
4343
BEGIN

sp_BlitzBackups.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ AS
2424
SET STATISTICS XML OFF;
2525
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
2626

27-
SELECT @Version = '8.24', @VersionDate = '20250407';
27+
SELECT @Version = '8.25', @VersionDate = '20250704';
2828

2929
IF(@VersionCheckMode = 1)
3030
BEGIN

sp_BlitzCache.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ SET NOCOUNT ON;
283283
SET STATISTICS XML OFF;
284284
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
285285

286-
SELECT @Version = '8.24', @VersionDate = '20250407';
286+
SELECT @Version = '8.25', @VersionDate = '20250704';
287287
SET @OutputType = UPPER(@OutputType);
288288

289289
IF(@VersionCheckMode = 1)

0 commit comments

Comments
 (0)