You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'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,
10152
10153
'KILL ' + CAST(r.session_id AS NVARCHAR(100)) + ';' AS HowToStopIt,
10153
10154
pl.query_plan AS QueryPlan,
10154
10155
r.start_time AS StartTime,
10155
10156
s.login_name AS LoginName,
10156
10157
s.nt_user_name AS NTUserName,
10157
10158
s.[program_name] AS ProgramName,
10158
10159
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,
10161
10162
0 AS OpenTransactionCount,
10162
10163
r.query_hash
10163
10164
FROM sys.dm_exec_requests r
10164
10165
INNER JOIN sys.dm_exec_connections c ON r.session_id = c.session_id
10165
10166
INNER JOIN sys.dm_exec_sessions s ON r.session_id = s.session_id
@@ -11835,6 +11859,53 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
11835
11859
OR max_session_percent >= 90);
11836
11860
END
11837
11861
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
+
11838
11909
/* Server Info - Batch Requests per Sec - CheckID 19 */
11839
11910
IF (@Debug = 1)
11840
11911
BEGIN
@@ -13164,13 +13235,13 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
13164
13235
wd1.wait_type,
13165
13236
COALESCE(wcat.WaitCategory, 'Other') AS wait_category,
13166
13237
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],
13169
13238
CASE WHEN (wd2.waiting_tasks_count - wd1.waiting_tasks_count) > 0
13170
13239
THEN
13171
13240
CAST((wd2.wait_time_ms-wd1.wait_time_ms)/
13172
13241
(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]
13174
13245
FROM max_batch b
13175
13246
JOIN #WaitStats wd2 ON
13176
13247
wd2.SampleTime =b.SampleTime
@@ -13309,17 +13380,17 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
13309
13380
wd1.wait_type,
13310
13381
COALESCE(wcat.WaitCategory, 'Other') AS wait_category,
13311
13382
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],
13312
13388
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],
13313
13389
CAST(c.[Signal Wait Time (Seconds)] / 60.0 / 60 AS DECIMAL(18,1)) AS [Signal Wait Time (Hours)],
13314
13390
CASE WHEN c.[Wait Time (Seconds)] > 0
13315
13391
THEN CAST(100.*(c.[Signal Wait Time (Seconds)]/c.[Wait Time (Seconds)]) AS NUMERIC(4,1))
13316
13392
ELSE 0 END AS [Percent Signal Waits],
13317
13393
(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],
13323
13394
N'https://www.sqlskills.com/help/waits/' + LOWER(wd1.wait_type) + '/' AS URL
13324
13395
FROM max_batch b
13325
13396
JOIN #WaitStats wd2 ON
@@ -13353,17 +13424,17 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
13353
13424
wd1.wait_type,
13354
13425
COALESCE(wcat.WaitCategory, 'Other') AS wait_category,
13355
13426
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],
13356
13432
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],
13357
13433
c.[Signal Wait Time (Seconds)],
13358
13434
CASE WHEN c.[Wait Time (Seconds)] > 0
13359
13435
THEN CAST(100.*(c.[Signal Wait Time (Seconds)]/c.[Wait Time (Seconds)]) AS NUMERIC(4,1))
13360
13436
ELSE 0 END AS [Percent Signal Waits],
13361
13437
(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],
13367
13438
N'https://www.sqlskills.com/help/waits/' + LOWER(wd1.wait_type) + '/' AS URL
0 commit comments