File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ function Get-DbaLatchStatistic {
9595 [latch_class],
9696 [wait_time_ms] / 1000.0 AS [WaitS],
9797 [waiting_requests_count] AS [WaitCount],
98- Case WHEN SUM ([wait_time_ms]) OVER() = 0 THEN NULL ELSE 100.0 * [wait_time_ms] / SUM ([wait_time_ms]) OVER() END AS [Percentage],
98+ CASE WHEN SUM([wait_time_ms]) OVER() > 0 THEN 100.0 * [wait_time_ms] / SUM([wait_time_ms]) OVER() END AS [Percentage],
9999 ROW_NUMBER() OVER(ORDER BY [wait_time_ms] DESC) AS [RowNum]
100100 FROM sys.dm_os_latch_stats
101101 WHERE [latch_class] NOT IN (N'BUFFER')
@@ -105,7 +105,7 @@ function Get-DbaLatchStatistic {
105105 CAST (MAX ([W1].[WaitS]) AS DECIMAL(14, 2)) AS [WaitSeconds],
106106 MAX ([W1].[WaitCount]) AS [WaitCount],
107107 CAST (MAX ([W1].[Percentage]) AS DECIMAL(14, 2)) AS [Percentage],
108- CAST (( MAX ([W1].[WaitS]) / MAX ([W1].[WaitCount])) AS DECIMAL (14, 4)) AS [AvgWaitSeconds],
108+ CAST (CASE WHEN MAX([W1].[WaitCount]) > 0 THEN MAX ([W1].[WaitS]) / MAX([W1].[WaitCount]) END AS DECIMAL (14, 4)) AS [AvgWaitSeconds],
109109 CAST ('https://www.sqlskills.com/help/latches/' + MAX ([W1].[latch_class]) as XML) AS [URL]
110110 FROM [Latches] AS [W1]
111111 INNER JOIN [Latches] AS [W2]
You can’t perform that action at this time.
0 commit comments