Skip to content

Commit 02296a4

Browse files
Issue #281 Gap 4: Remove session_wait_stats (zero UI, full removal)
Remove collect.session_wait_stats entirely — table, collector procedure, reporting view, schedule entries, schema metadata, CI checks, and all references. This collector had 12 columns and zero UI in either app. Adds cleanup DROPs to 02_create_tables.sql so existing installations get cleaned up on upgrade (drops view, procedure, table, schedule row). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ef4ed0c commit 02296a4

12 files changed

Lines changed: 12 additions & 514 deletions

.github/sql/ci_validate_installation.sql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ IF SCHEMA_ID(N'report') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: sche
3030
PRINT '';
3131

3232
/*
33-
Procedures in collect schema (37)
33+
Procedures in collect schema (36)
3434
*/
3535
PRINT 'Checking collect procedures...';
3636

@@ -65,7 +65,6 @@ IF OBJECT_ID(N'collect.tempdb_stats_collector', N'P') IS NULL BEGIN SE
6565
IF OBJECT_ID(N'collect.plan_cache_stats_collector', N'P') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: collect.plan_cache_stats_collector'; END; SET @checked += 1;
6666
IF OBJECT_ID(N'collect.session_stats_collector', N'P') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: collect.session_stats_collector'; END; SET @checked += 1;
6767
IF OBJECT_ID(N'collect.waiting_tasks_collector', N'P') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: collect.waiting_tasks_collector'; END; SET @checked += 1;
68-
IF OBJECT_ID(N'collect.session_wait_stats_collector', N'P') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: collect.session_wait_stats_collector'; END; SET @checked += 1;
6968
IF OBJECT_ID(N'collect.server_configuration_collector', N'P') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: collect.server_configuration_collector'; END; SET @checked += 1;
7069
IF OBJECT_ID(N'collect.database_configuration_collector', N'P') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: collect.database_configuration_collector'; END; SET @checked += 1;
7170
IF OBJECT_ID(N'collect.configuration_issues_analyzer', N'P') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: collect.configuration_issues_analyzer'; END; SET @checked += 1;
@@ -142,7 +141,6 @@ IF OBJECT_ID(N'report.blocking_chain_analysis', N'V') IS NULL BEGIN
142141
IF OBJECT_ID(N'report.tempdb_contention_analysis', N'V') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: report.tempdb_contention_analysis'; END; SET @checked += 1;
143142
IF OBJECT_ID(N'report.parameter_sensitivity_detection', N'V') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: report.parameter_sensitivity_detection'; END; SET @checked += 1;
144143
IF OBJECT_ID(N'report.scheduler_cpu_analysis', N'V') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: report.scheduler_cpu_analysis'; END; SET @checked += 1;
145-
IF OBJECT_ID(N'report.session_wait_analysis', N'V') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: report.session_wait_analysis'; END; SET @checked += 1;
146144
IF OBJECT_ID(N'report.critical_issues', N'V') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: report.critical_issues'; END; SET @checked += 1;
147145
IF OBJECT_ID(N'report.memory_usage_trends', N'V') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: report.memory_usage_trends'; END; SET @checked += 1;
148146
IF OBJECT_ID(N'report.running_jobs', N'V') IS NULL BEGIN SET @missing += 1; PRINT ' MISSING: report.running_jobs'; END; SET @checked += 1;
@@ -182,7 +180,7 @@ WHERE OBJECT_SCHEMA_NAME(t.object_id) = N'config';
182180
PRINT ' collect schema tables: ' + CONVERT(varchar(10), @collect_tables);
183181
PRINT ' config schema tables: ' + CONVERT(varchar(10), @config_tables);
184182

185-
IF @collect_tables < 20 BEGIN SET @missing += 1; PRINT ' MISSING: expected >= 20 collect tables, found ' + CONVERT(varchar(10), @collect_tables); END; SET @checked += 1;
183+
IF @collect_tables < 19 BEGIN SET @missing += 1; PRINT ' MISSING: expected >= 20 collect tables, found ' + CONVERT(varchar(10), @collect_tables); END; SET @checked += 1;
186184
IF @config_tables < 5 BEGIN SET @missing += 1; PRINT ' MISSING: expected >= 5 config tables, found ' + CONVERT(varchar(10), @config_tables); END; SET @checked += 1;
187185

188186
PRINT '';

Dashboard/schema/tables.json

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -677,26 +677,5 @@
677677
"row_count": { "type": "bigint", "nullable": true }
678678
},
679679
"primary_key": ["collection_id"]
680-
},
681-
"collect.session_wait_stats": {
682-
"description": "Per-session wait statistics from sys.dm_exec_session_wait_stats (SQL 2016 SP1+)",
683-
"columns": {
684-
"collection_id": { "type": "bigint", "nullable": false, "identity": true },
685-
"collection_time": { "type": "datetime2(7)", "nullable": false },
686-
"session_id": { "type": "integer", "nullable": false },
687-
"wait_type": { "type": "nvarchar(60)", "nullable": false },
688-
"waiting_tasks_count": { "type": "bigint", "nullable": false },
689-
"wait_time_ms": { "type": "bigint", "nullable": false },
690-
"max_wait_time_ms": { "type": "bigint", "nullable": false },
691-
"signal_wait_time_ms": { "type": "bigint", "nullable": false },
692-
"database_id": { "type": "integer", "nullable": true },
693-
"database_name": { "type": "sysname", "nullable": true },
694-
"login_name": { "type": "nvarchar(128)", "nullable": true },
695-
"host_name": { "type": "nvarchar(128)", "nullable": true },
696-
"program_name": { "type": "nvarchar(128)", "nullable": true },
697-
"sql_handle": { "type": "varbinary(64)", "nullable": true },
698-
"query_text": { "type": "nvarchar(max)", "nullable": true }
699-
},
700-
"primary_key": ["collection_id"]
701680
}
702681
}

install/02_create_tables.sql

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ GO
1818
USE PerformanceMonitor;
1919
GO
2020

21+
/*
22+
Cleanup: session_wait_stats removed in v1.4
23+
*/
24+
IF OBJECT_ID(N'report.session_wait_analysis', N'V') IS NOT NULL DROP VIEW report.session_wait_analysis;
25+
IF OBJECT_ID(N'collect.session_wait_stats_collector', N'P') IS NOT NULL DROP PROCEDURE collect.session_wait_stats_collector;
26+
IF OBJECT_ID(N'collect.session_wait_stats', N'U') IS NOT NULL DROP TABLE collect.session_wait_stats;
27+
IF OBJECT_ID(N'config.collection_schedule', N'U') IS NOT NULL DELETE FROM config.collection_schedule WHERE collector_name = N'session_wait_stats_collector';
28+
GO
29+
2130
/*
2231
Collection tables for the 7 core collectors
2332
*/
@@ -1277,49 +1286,6 @@ BEGIN
12771286
PRINT 'Created collect.waiting_tasks table';
12781287
END;
12791288

1280-
/*
1281-
Table: collect.session_wait_stats
1282-
Purpose: Captures per-session wait statistics from sys.dm_exec_session_wait_stats
1283-
Collection Frequency: Every 60 seconds (alongside query snapshots)
1284-
Type: Snapshot (resets on session end)
1285-
Dependencies: None
1286-
Notes: Correlates with query_snapshots to show waits for specific sessions
1287-
Requires SQL Server 2016 SP1 or later
1288-
*/
1289-
IF OBJECT_ID(N'collect.session_wait_stats', N'U') IS NULL
1290-
BEGIN
1291-
CREATE TABLE
1292-
collect.session_wait_stats
1293-
(
1294-
collection_id bigint IDENTITY NOT NULL,
1295-
collection_time datetime2(7) NOT NULL
1296-
DEFAULT SYSDATETIME(),
1297-
session_id integer NOT NULL,
1298-
wait_type nvarchar(60) NOT NULL,
1299-
waiting_tasks_count bigint NOT NULL,
1300-
wait_time_ms bigint NOT NULL,
1301-
max_wait_time_ms bigint NOT NULL,
1302-
signal_wait_time_ms bigint NOT NULL,
1303-
/*Session context for correlation*/
1304-
database_id integer NULL,
1305-
database_name sysname NULL,
1306-
login_name nvarchar(128) NULL,
1307-
host_name nvarchar(128) NULL,
1308-
program_name nvarchar(128) NULL,
1309-
/*Query context if executing*/
1310-
sql_handle varbinary(64) NULL,
1311-
query_text nvarchar(max) NULL,
1312-
CONSTRAINT
1313-
PK_session_wait_stats
1314-
PRIMARY KEY CLUSTERED
1315-
(collection_time, collection_id)
1316-
WITH
1317-
(DATA_COMPRESSION = PAGE)
1318-
);
1319-
1320-
PRINT 'Created collect.session_wait_stats table';
1321-
END;
1322-
13231289
/*
13241290
Running Jobs Monitor (Point-in-Time Snapshot)
13251291
Captures currently running SQL Agent jobs with historical duration comparison

install/03_create_config_tables.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ BEGIN
202202
(N'plan_cache_stats_collector', 1, 60, 5, 30, N'Plan cache composition statistics - single-use plans and plan cache bloat detection'),
203203
(N'session_stats_collector', 1, 5, 2, 30, N'Session and connection statistics - connection leaks and application patterns'),
204204
(N'waiting_tasks_collector', 1, 5, 2, 30, N'Currently waiting tasks - blocking chains and wait analysis'),
205-
(N'session_wait_stats_collector', 1, 1, 2, 30, N'Per-session wait statistics - correlates waits with specific sessions/queries (requires SQL Server 2016 SP1+)'),
206205
(N'running_jobs_collector', 1, 5, 2, 7, N'Currently running SQL Agent jobs with historical duration comparison');
207206

208207
/*

install/04_create_schedule_table.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ FROM
7474
(N'plan_cache_stats_collector', 1, 5, 5, 30, N'Plan cache composition statistics - single-use plans and plan cache bloat detection'),
7575
(N'session_stats_collector', 1, 1, 2, 30, N'Session and connection statistics - connection leaks and application patterns'),
7676
(N'waiting_tasks_collector', 1, 1, 2, 30, N'Currently waiting tasks - blocking chains and wait analysis'),
77-
(N'session_wait_stats_collector', 1, 1, 2, 30, N'Per-session wait statistics - correlates waits with specific sessions/queries (requires SQL Server 2016 SP1+)'),
7877
(N'running_jobs_collector', 1, 1, 2, 7, N'Currently running SQL Agent jobs with historical duration comparison')
7978
) AS v (collector_name, enabled, frequency_minutes, max_duration_minutes, retention_days, description)
8079
WHERE NOT EXISTS

install/06_ensure_collection_table.sql

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,38 +1054,6 @@ BEGIN
10541054
(DATA_COMPRESSION = PAGE)
10551055
);
10561056

1057-
END;
1058-
ELSE IF @table_name = N'session_wait_stats'
1059-
BEGIN
1060-
CREATE TABLE
1061-
collect.session_wait_stats
1062-
(
1063-
collection_id bigint IDENTITY NOT NULL,
1064-
collection_time datetime2(7) NOT NULL
1065-
DEFAULT SYSDATETIME(),
1066-
session_id integer NOT NULL,
1067-
wait_type nvarchar(60) NOT NULL,
1068-
waiting_tasks_count bigint NOT NULL,
1069-
wait_time_ms bigint NOT NULL,
1070-
max_wait_time_ms bigint NOT NULL,
1071-
signal_wait_time_ms bigint NOT NULL,
1072-
/*Session context for correlation*/
1073-
database_id integer NULL,
1074-
database_name sysname NULL,
1075-
login_name nvarchar(128) NULL,
1076-
host_name nvarchar(128) NULL,
1077-
program_name nvarchar(128) NULL,
1078-
/*Query context if executing*/
1079-
sql_handle varbinary(64) NULL,
1080-
query_text nvarchar(max) NULL,
1081-
CONSTRAINT
1082-
PK_session_wait_stats
1083-
PRIMARY KEY CLUSTERED
1084-
(collection_time, collection_id)
1085-
WITH
1086-
(DATA_COMPRESSION = PAGE)
1087-
);
1088-
10891057
END;
10901058
ELSE IF @table_name = N'running_jobs'
10911059
BEGIN
@@ -1117,7 +1085,7 @@ BEGIN
11171085
END;
11181086
ELSE
11191087
BEGIN
1120-
SET @error_message = N'Unknown table name: ' + @table_name + N'. Valid table names are: wait_stats, query_stats, memory_stats, memory_pressure_events, deadlock_xml, blocked_process_xml, procedure_stats, query_snapshots, query_store_data, trace_analysis, default_trace_events, file_io_stats, memory_grant_stats, cpu_scheduler_stats, memory_clerks_stats, perfmon_stats, cpu_utilization_stats, blocking_deadlock_stats, latch_stats, spinlock_stats, tempdb_stats, plan_cache_stats, session_stats, waiting_tasks, session_wait_stats, running_jobs';
1088+
SET @error_message = N'Unknown table name: ' + @table_name + N'. Valid table names are: wait_stats, query_stats, memory_stats, memory_pressure_events, deadlock_xml, blocked_process_xml, procedure_stats, query_snapshots, query_store_data, trace_analysis, default_trace_events, file_io_stats, memory_grant_stats, cpu_scheduler_stats, memory_clerks_stats, perfmon_stats, cpu_utilization_stats, blocking_deadlock_stats, latch_stats, spinlock_stats, tempdb_stats, plan_cache_stats, session_stats, waiting_tasks, running_jobs';
11211089
RAISERROR(@error_message, 16, 1);
11221090
RETURN;
11231091
END;

0 commit comments

Comments
 (0)