Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lite/Database/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ internal_object_reserved_mb DECIMAL(18,2),
version_store_reserved_mb DECIMAL(18,2),
total_reserved_mb DECIMAL(18,2),
unallocated_mb DECIMAL(18,2),
total_sessions_using_tempdb INTEGER,
total_sessions_using_tempdb BIGINT,
top_session_id INTEGER,
top_session_tempdb_mb DECIMAL(18,2)
)";
Expand Down Expand Up @@ -652,7 +652,7 @@ CREATE TABLE IF NOT EXISTS session_stats (
server_id INTEGER NOT NULL,
server_name VARCHAR NOT NULL,
program_name VARCHAR NOT NULL,
connection_count INTEGER NOT NULL,
connection_count BIGINT NOT NULL,
running_count INTEGER NOT NULL,
sleeping_count INTEGER NOT NULL,
dormant_count INTEGER NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion Lite/Services/RemoteCollectorService.SessionStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ORDER BY
while (await reader.ReadAsync(cancellationToken))
{
var programName = reader.GetString(0);
var connectionCount = Convert.ToInt32(reader.GetValue(1));
var connectionCount = Convert.ToInt64(reader.GetValue(1));
var runningCount = Convert.ToInt32(reader.GetValue(2));
var sleepingCount = Convert.ToInt32(reader.GetValue(3));
var dormantCount = Convert.ToInt32(reader.GetValue(4));
Expand Down
5 changes: 3 additions & 2 deletions Lite/Services/RemoteCollectorService.TempDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ ORDER BY (ssu.user_objects_alloc_page_count + ssu.internal_objects_alloc_page_co
using var reader = await command.ExecuteReaderAsync(cancellationToken);

decimal userObjMb = 0, internalObjMb = 0, versionStoreMb = 0, totalReservedMb = 0, unallocatedMb = 0;
int topSessionId = 0, totalSessions = 0;
int topSessionId = 0;
long totalSessions = 0;
decimal topSessionMb = 0;

if (await reader.ReadAsync(cancellationToken))
Expand All @@ -73,7 +74,7 @@ ORDER BY (ssu.user_objects_alloc_page_count + ssu.internal_objects_alloc_page_co
{
topSessionId = reader.IsDBNull(0) ? 0 : Convert.ToInt32(reader.GetValue(0));
topSessionMb = reader.IsDBNull(1) ? 0m : reader.GetDecimal(1);
totalSessions = reader.IsDBNull(2) ? 0 : (int)reader.GetInt64(2);
totalSessions = reader.IsDBNull(2) ? 0L : reader.GetInt64(2);
}
sqlSw.Stop();

Expand Down
12 changes: 6 additions & 6 deletions install/02_create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -818,13 +818,13 @@ BEGIN
scheduler_count integer NULL,
cpu_count integer NULL,
total_runnable_tasks_count integer NULL,
total_work_queue_count integer NULL,
total_work_queue_count bigint NULL,
total_current_workers_count integer NULL,
avg_runnable_tasks_count decimal(38,2) NULL,
total_active_request_count integer NULL,
total_queued_request_count integer NULL,
total_blocked_task_count integer NULL,
total_active_parallel_thread_count integer NULL,
total_active_parallel_thread_count bigint NULL,
runnable_request_count integer NULL,
total_request_count integer NULL,
runnable_percent decimal(38,2) NULL,
Expand All @@ -836,7 +836,7 @@ BEGIN
/*OS Memory metrics from sys.dm_os_sys_memory*/
total_physical_memory_kb bigint NULL,
available_physical_memory_kb bigint NULL,
system_memory_state_desc nvarchar(120) NULL,
system_memory_state_desc nvarchar(256) NULL,
physical_memory_pressure_warning bit NULL,
/*NUMA node metrics from sys.dm_os_nodes*/
total_node_count integer NULL,
Expand Down Expand Up @@ -1346,7 +1346,7 @@ BEGIN
wait_type nvarchar(60) NOT NULL,
wait_duration_ms bigint NOT NULL,
blocking_session_id integer NOT NULL,
resource_description nvarchar(1000) NULL,
resource_description nvarchar(3072) NULL,
database_id integer NULL,
database_name sysname NULL,
query_text nvarchar(max) NULL,
Expand Down Expand Up @@ -1427,10 +1427,10 @@ BEGIN
used_size_mb decimal(19,2) NULL,
auto_growth_mb decimal(19,2) NULL,
max_size_mb decimal(19,2) NULL,
recovery_model_desc nvarchar(12) NULL,
recovery_model_desc nvarchar(60) NULL,
compatibility_level integer NULL,
state_desc nvarchar(60) NULL,
volume_mount_point nvarchar(256) NULL,
volume_mount_point nvarchar(512) NULL,
volume_total_mb decimal(19,2) NULL,
volume_free_mb decimal(19,2) NULL,
/*Analysis helpers - computed columns*/
Expand Down
12 changes: 6 additions & 6 deletions install/06_ensure_collection_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,13 @@ BEGIN
scheduler_count integer NULL,
cpu_count integer NULL,
total_runnable_tasks_count integer NULL,
total_work_queue_count integer NULL,
total_work_queue_count bigint NULL,
total_current_workers_count integer NULL,
avg_runnable_tasks_count decimal(38,2) NULL,
total_active_request_count integer NULL,
total_queued_request_count integer NULL,
total_blocked_task_count integer NULL,
total_active_parallel_thread_count integer NULL,
total_active_parallel_thread_count bigint NULL,
runnable_request_count integer NULL,
total_request_count integer NULL,
runnable_percent decimal(38,2) NULL,
Expand All @@ -731,7 +731,7 @@ BEGIN
/*OS Memory metrics from sys.dm_os_sys_memory*/
total_physical_memory_kb bigint NULL,
available_physical_memory_kb bigint NULL,
system_memory_state_desc nvarchar(120) NULL,
system_memory_state_desc nvarchar(256) NULL,
physical_memory_pressure_warning bit NULL,
/*NUMA node metrics from sys.dm_os_nodes*/
total_node_count integer NULL,
Expand Down Expand Up @@ -1037,7 +1037,7 @@ BEGIN
wait_type nvarchar(60) NOT NULL,
wait_duration_ms bigint NOT NULL,
blocking_session_id integer NOT NULL,
resource_description nvarchar(1000) NULL,
resource_description nvarchar(3072) NULL,
database_id integer NULL,
database_name sysname NULL,
query_text nvarchar(max) NULL,
Expand Down Expand Up @@ -1107,10 +1107,10 @@ BEGIN
used_size_mb decimal(19,2) NULL,
auto_growth_mb decimal(19,2) NULL,
max_size_mb decimal(19,2) NULL,
recovery_model_desc nvarchar(12) NULL,
recovery_model_desc nvarchar(60) NULL,
compatibility_level integer NULL,
state_desc nvarchar(60) NULL,
volume_mount_point nvarchar(256) NULL,
volume_mount_point nvarchar(512) NULL,
volume_total_mb decimal(19,2) NULL,
volume_free_mb decimal(19,2) NULL,
free_space_mb AS
Expand Down
2 changes: 1 addition & 1 deletion install/52_collect_database_size_stats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ BEGIN
ELSE CONVERT(decimal(19,2), df.max_size * 8.0 / 1024.0)
END,
recovery_model_desc =
CONVERT(nvarchar(12), DATABASEPROPERTYEX(DB_NAME(), N'Recovery')),
CONVERT(nvarchar(60), DATABASEPROPERTYEX(DB_NAME(), N'Recovery')),
compatibility_level = NULL,
state_desc = N'ONLINE',
volume_mount_point = NULL,
Expand Down
156 changes: 156 additions & 0 deletions upgrades/2.2.0-to-2.3.0/02_widen_audit_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/*
Copyright 2026 Darling Data, LLC
https://www.erikdarling.com/

Upgrade from 2.2.0 to 2.3.0
Widens collector table columns to match DMV documentation:

cpu_scheduler_stats:
- total_work_queue_count: integer -> bigint (dm_os_schedulers.work_queue_count is bigint)
- total_active_parallel_thread_count: integer -> bigint (dm_resource_governor_workload_groups.active_parallel_thread_count is bigint)
- system_memory_state_desc: nvarchar(120) -> nvarchar(256) (dm_os_sys_memory documents nvarchar(256))

waiting_tasks:
- resource_description: nvarchar(1000) -> nvarchar(3072) (dm_os_waiting_tasks documents nvarchar(3072))

database_size_stats:
- recovery_model_desc: nvarchar(12) -> nvarchar(60) (sys.databases documents nvarchar(60))
- volume_mount_point: nvarchar(256) -> nvarchar(512) (dm_os_volume_stats documents nvarchar(512))
*/

SET ANSI_NULLS ON;
SET ANSI_PADDING ON;
SET ANSI_WARNINGS ON;
SET ARITHABORT ON;
SET CONCAT_NULL_YIELDS_NULL ON;
SET QUOTED_IDENTIFIER ON;
SET NUMERIC_ROUNDABORT OFF;
SET IMPLICIT_TRANSACTIONS OFF;
SET STATISTICS TIME, IO OFF;
GO

USE PerformanceMonitor;
GO

/*
cpu_scheduler_stats: widen integer columns to bigint
*/
IF OBJECT_ID(N'collect.cpu_scheduler_stats', N'U') IS NOT NULL
BEGIN
PRINT 'Checking collect.cpu_scheduler_stats columns...';

IF EXISTS
(
SELECT
1/0
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = N'collect'
AND TABLE_NAME = N'cpu_scheduler_stats'
AND COLUMN_NAME = N'total_work_queue_count'
AND DATA_TYPE = N'int'
)
BEGIN
ALTER TABLE collect.cpu_scheduler_stats ALTER COLUMN total_work_queue_count bigint NULL;
PRINT ' total_work_queue_count: int -> bigint';
END;

IF EXISTS
(
SELECT
1/0
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = N'collect'
AND TABLE_NAME = N'cpu_scheduler_stats'
AND COLUMN_NAME = N'total_active_parallel_thread_count'
AND DATA_TYPE = N'int'
)
BEGIN
ALTER TABLE collect.cpu_scheduler_stats ALTER COLUMN total_active_parallel_thread_count bigint NULL;
PRINT ' total_active_parallel_thread_count: int -> bigint';
END;

IF EXISTS
(
SELECT
1/0
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = N'collect'
AND TABLE_NAME = N'cpu_scheduler_stats'
AND COLUMN_NAME = N'system_memory_state_desc'
AND CHARACTER_MAXIMUM_LENGTH = 120
)
BEGIN
ALTER TABLE collect.cpu_scheduler_stats ALTER COLUMN system_memory_state_desc nvarchar(256) NULL;
PRINT ' system_memory_state_desc: nvarchar(120) -> nvarchar(256)';
END;

PRINT 'cpu_scheduler_stats complete.';
END;
GO

/*
waiting_tasks: widen resource_description
*/
IF OBJECT_ID(N'collect.waiting_tasks', N'U') IS NOT NULL
BEGIN
PRINT 'Checking collect.waiting_tasks columns...';

IF EXISTS
(
SELECT
1/0
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = N'collect'
AND TABLE_NAME = N'waiting_tasks'
AND COLUMN_NAME = N'resource_description'
AND CHARACTER_MAXIMUM_LENGTH = 1000
)
BEGIN
ALTER TABLE collect.waiting_tasks ALTER COLUMN resource_description nvarchar(3072) NULL;
PRINT ' resource_description: nvarchar(1000) -> nvarchar(3072)';
END;

PRINT 'waiting_tasks complete.';
END;
GO

/*
database_size_stats: widen string columns
*/
IF OBJECT_ID(N'collect.database_size_stats', N'U') IS NOT NULL
BEGIN
PRINT 'Checking collect.database_size_stats columns...';

IF EXISTS
(
SELECT
1/0
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = N'collect'
AND TABLE_NAME = N'database_size_stats'
AND COLUMN_NAME = N'recovery_model_desc'
AND CHARACTER_MAXIMUM_LENGTH = 12
)
BEGIN
ALTER TABLE collect.database_size_stats ALTER COLUMN recovery_model_desc nvarchar(60) NULL;
PRINT ' recovery_model_desc: nvarchar(12) -> nvarchar(60)';
END;

IF EXISTS
(
SELECT
1/0
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = N'collect'
AND TABLE_NAME = N'database_size_stats'
AND COLUMN_NAME = N'volume_mount_point'
AND CHARACTER_MAXIMUM_LENGTH = 256
)
BEGIN
ALTER TABLE collect.database_size_stats ALTER COLUMN volume_mount_point nvarchar(512) NULL;
PRINT ' volume_mount_point: nvarchar(256) -> nvarchar(512)';
END;

PRINT 'database_size_stats complete.';
END;
GO
1 change: 1 addition & 0 deletions upgrades/2.2.0-to-2.3.0/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
01_widen_query_stats_columns.sql
02_widen_audit_columns.sql
Loading