Skip to content

Commit f9fc343

Browse files
Add @skip_waits parameter to sp_HealthParser
Mirrors the existing @skip_locks pattern to allow callers to skip the wait stats section (significant waits, waits by count, waits by duration). This is critical for monitoring tools that use table logging mode but don't consume wait data. Benchmarked on SQL2022 with @warnings_only = 1, @log_to_table = 1: - No skips: 43,233ms - @skip_locks only: 2,257ms - @skip_waits only: 38,017ms - Both skips: 1,605ms (27x improvement) Version bumped to 3.3 (20260216). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3677cd4 commit f9fc343

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

sp_HealthParser/sp_HealthParser.sql

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ALTER PROCEDURE
4949
@wait_duration_ms bigint = 500, /*Minimum duration to show query waits*/
5050
@wait_round_interval_minutes bigint = 60, /*Nearest interval to round wait stats to*/
5151
@skip_locks bit = 0, /*Skip the blocking and deadlocks*/
52+
@skip_waits bit = 0, /*Skip the wait stats*/
5253
@pending_task_threshold integer = 10, /*Minimum number of pending tasks to care about*/
5354
@log_to_table bit = 0, /*enable logging to permanent tables*/
5455
@log_database_name sysname = NULL, /*database to store logging tables*/
@@ -70,8 +71,8 @@ BEGIN
7071
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
7172

7273
SELECT
73-
@version = '3.2.5',
74-
@version_date = '20260206';
74+
@version = '3.3',
75+
@version_date = '20260216';
7576

7677
IF @help = 1
7778
BEGIN
@@ -101,6 +102,7 @@ BEGIN
101102
WHEN N'@wait_duration_ms' THEN N'minimum wait duration'
102103
WHEN N'@wait_round_interval_minutes' THEN N'interval to round minutes to for wait stats'
103104
WHEN N'@skip_locks' THEN N'skip the blocking and deadlocking section'
105+
WHEN N'@skip_waits' THEN N'skip the wait stats section'
104106
WHEN N'@pending_task_threshold' THEN N'minimum number of pending tasks to display'
105107
WHEN N'@log_to_table' THEN N'enable logging to permanent tables instead of returning results'
106108
WHEN N'@log_database_name' THEN N'database to store logging tables'
@@ -123,6 +125,7 @@ BEGIN
123125
WHEN N'@wait_duration_ms' THEN N'the minimum duration of a wait for queries with interesting waits'
124126
WHEN N'@wait_round_interval_minutes' THEN N'interval to round minutes to for top wait stats by count and duration'
125127
WHEN N'@skip_locks' THEN N'0 or 1'
128+
WHEN N'@skip_waits' THEN N'0 or 1'
126129
WHEN N'@pending_task_threshold' THEN N'a valid integer'
127130
WHEN N'@log_to_table' THEN N'0 or 1'
128131
WHEN N'@log_database_name' THEN N'any valid database name'
@@ -145,6 +148,7 @@ BEGIN
145148
WHEN N'@wait_duration_ms' THEN N'500'
146149
WHEN N'@wait_round_interval_minutes' THEN N'60'
147150
WHEN N'@skip_locks' THEN N'0'
151+
WHEN N'@skip_waits' THEN N'0'
148152
WHEN N'@pending_task_threshold' THEN N'10'
149153
WHEN N'@log_to_table' THEN N'0'
150154
WHEN N'@log_database_name' THEN N'NULL (current database)'
@@ -456,6 +460,7 @@ AND ca.utc_timestamp < @end_date';
456460
@wait_duration_ms = ISNULL(@wait_duration_ms, 500),
457461
@wait_round_interval_minutes = ISNULL(@wait_round_interval_minutes, 60),
458462
@skip_locks = ISNULL(@skip_locks, 0),
463+
@skip_waits = ISNULL(@skip_waits, 0),
459464
@pending_task_threshold = ISNULL(@pending_task_threshold, 10);
460465

461466
/*Validate what to check*/
@@ -1348,6 +1353,9 @@ AND ca.utc_timestamp < @end_date';
13481353
WHEN v.area_name = 'locking'
13491354
AND @skip_locks = 1
13501355
THEN 0
1356+
WHEN v.area_name = 'waits'
1357+
AND @skip_waits = 1
1358+
THEN 0
13511359
ELSE 1
13521360
END
13531361
WHEN @what_to_check = v.area_name
@@ -1454,7 +1462,8 @@ AND ca.utc_timestamp < @end_date';
14541462
);
14551463

14561464
/*The more you ignore waits, the worser they get*/
1457-
IF @what_to_check IN ('all', 'waits')
1465+
IF @what_to_check IN ('all', 'waits')
1466+
AND @skip_waits = 0
14581467
BEGIN
14591468
IF @debug = 1
14601469
BEGIN
@@ -1674,7 +1683,8 @@ AND ca.utc_timestamp < @end_date';
16741683
FROM #ring_buffer AS x;
16751684
END;
16761685

1677-
IF @what_to_check IN ('all', 'waits')
1686+
IF @what_to_check IN ('all', 'waits')
1687+
AND @skip_waits = 0
16781688
BEGIN
16791689
IF @debug = 1
16801690
BEGIN
@@ -1883,7 +1893,8 @@ AND ca.utc_timestamp < @end_date';
18831893
END;
18841894

18851895
/*Parse out the wait_info data*/
1886-
IF @what_to_check IN ('all', 'waits')
1896+
IF @what_to_check IN ('all', 'waits')
1897+
AND @skip_waits = 0
18871898
BEGIN
18881899
IF @debug = 1
18891900
BEGIN
@@ -1969,6 +1980,8 @@ AND ca.utc_timestamp < @end_date';
19691980
WHEN @what_to_check NOT IN ('all', 'waits')
19701981
THEN 'waits skipped, @what_to_check set to ' +
19711982
@what_to_check
1983+
WHEN @skip_waits = 1
1984+
THEN 'waits skipped, @skip_waits set to 1'
19721985
WHEN @what_to_check IN ('all', 'waits')
19731986
THEN 'no queries with significant waits found between ' +
19741987
RTRIM(CONVERT(date, @start_date)) +
@@ -2221,6 +2234,8 @@ AND ca.utc_timestamp < @end_date';
22212234
WHEN @what_to_check NOT IN ('all', 'waits')
22222235
THEN 'waits skipped, @what_to_check set to ' +
22232236
@what_to_check
2237+
WHEN @skip_waits = 1
2238+
THEN 'waits skipped, @skip_waits set to 1'
22242239
WHEN @what_to_check IN ('all', 'waits')
22252240
THEN 'no significant waits found between ' +
22262241
RTRIM(CONVERT(date, @start_date)) +
@@ -2479,6 +2494,8 @@ AND ca.utc_timestamp < @end_date';
24792494
WHEN @what_to_check NOT IN ('all', 'waits')
24802495
THEN 'waits skipped, @what_to_check set to ' +
24812496
@what_to_check
2497+
WHEN @skip_waits = 1
2498+
THEN 'waits skipped, @skip_waits set to 1'
24822499
WHEN @what_to_check IN ('all', 'waits')
24832500
THEN 'no significant waits found between ' +
24842501
RTRIM(CONVERT(date, @start_date)) +

0 commit comments

Comments
 (0)