diff --git a/sp_PressureDetector/sp_PressureDetector.sql b/sp_PressureDetector/sp_PressureDetector.sql index 6057b7f..720007a 100644 --- a/sp_PressureDetector/sp_PressureDetector.sql +++ b/sp_PressureDetector/sp_PressureDetector.sql @@ -769,7 +769,7 @@ OPTION(MAXDOP 1, RECOMPILE);', (w2.hours_wait_time - w.hours_wait_time) / 1000. ), avg_ms_per_wait = - (w2.avg_ms_per_wait - w.avg_ms_per_wait), + (w2.avg_ms_per_wait + w.avg_ms_per_wait) / 2, percent_signal_waits = CONVERT ( @@ -902,7 +902,12 @@ OPTION(MAXDOP 1, RECOMPILE);', CONVERT ( decimal(38, 2), - vfs.io_stall_read_ms / (1.0 * vfs.num_of_reads) + ISNULL + ( + vfs.io_stall_read_ms / + (1.0 * NULLIF(vfs.num_of_reads, 0)), + 0 + ) ), total_gb_written = CASE @@ -920,7 +925,12 @@ OPTION(MAXDOP 1, RECOMPILE);', CONVERT ( decimal(38, 2), - vfs.io_stall_write_ms / (1.0 * vfs.num_of_writes) + ISNULL + ( + vfs.io_stall_write_ms / + (1.0 * NULLIF(vfs.num_of_writes, 0)), + 0 + ) ), sample_time = GETDATE() @@ -939,8 +949,11 @@ OPTION(MAXDOP 1, RECOMPILE);', AND vfs.database_id = f.database_id' END + N' - WHERE vfs.num_of_reads > 0 - AND vfs.num_of_writes > 0;' + WHERE + ( + vfs.num_of_reads > 0 + OR vfs.num_of_writes > 0 + );' ); IF @debug = 1