Skip to content

Commit 7452f95

Browse files
Fix runnable percent bug
The percentage of user queries in a suspended state was incorrect.
1 parent e7ca0a6 commit 7452f95

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

sp_PressureDetector/sp_PressureDetector.sql

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3675,14 +3675,14 @@ OPTION(MAXDOP 1, RECOMPILE);',
36753675
(
36763676
decimal(38,2),
36773677
(
3678-
x.runnable / (1. * NULLIF(x.total, 0))
3678+
x.runnable /
3679+
(1. * NULLIF(x.total, 0))
36793680
)
36803681
) * 100.
36813682
FROM
36823683
(
36833684
SELECT
3684-
total =
3685-
COUNT_BIG(*),
3685+
total = COUNT_BIG(*),
36863686
runnable =
36873687
SUM
36883688
(
@@ -3694,6 +3694,8 @@ OPTION(MAXDOP 1, RECOMPILE);',
36943694
)
36953695
FROM sys.dm_exec_requests AS der
36963696
WHERE der.session_id > 50
3697+
AND der.session_id <> @@SPID
3698+
AND der.status NOT IN (N''background'', N''sleeping'')
36973699
) AS x
36983700
) AS y
36993701
WHERE y.runnable_pct >= 10
@@ -3705,6 +3707,11 @@ OPTION(MAXDOP 1, RECOMPILE);',
37053707

37063708
IF @log_to_table = 0
37073709
BEGIN
3710+
IF @debug = 1
3711+
BEGIN
3712+
PRINT @cpu_threads;
3713+
END;
3714+
37083715
EXECUTE sys.sp_executesql
37093716
@cpu_threads;
37103717
END;

0 commit comments

Comments
 (0)