我有一个通用的日志表,可以附加到进程及其结果。我使用流程性能视图获得平均时间:
WITH Events
AS (
SELECT PR.DATA_DT_ID
,P.ProcessID
,P.ProcessName
,PL.GUID
,PL.EventText
,PL.EventTime
FROM MISProcess.ProcessResults AS PR
INNER JOIN MISProcess.ProcessResultTypes AS PRT
ON PRT.ResultTypeID = PR.ResultTypeID
AND PRT.IsCompleteForTiming = 1
INNER JOIN MISProcess.Process AS P
ON P.ProcessID = PR.ProcessID
INNER JOIN MISProcess.ProcessLog AS PL
ON PL.BatchRunID = PR.BatchRunID
AND PL.ProcessID = P.ProcessID
AND [GUID] IS NOT NULL
AND (
PL.EventText LIKE 'Process Starting:%'
OR PL.EventText LIKE 'Process Complete:%'
)
)
SELECT Start.DATA_DT_ID
,Start.ProcessName
,AVG(DATEDIFF(SECOND, Start.EventTime, Finish.EventTime)) AS AvgDurationSeconds
,COUNT(*) AS NumRuns
FROM Events AS Start
INNER JOIN Events AS Finish
ON Start.EventText LIKE 'Process Starting:%'
AND Finish.EventText LIKE 'Process Complete:%'
AND Start.DATA_DT_ID = Finish.DATA_DT_ID
AND Start.ProcessID = Finish.ProcessID
AND Start.GUID = Finish.GUID
GROUP BY Start.DATA_DT_ID
,Start.ProcessName
现在我可以过滤掉这一点来消除以前几个月的运行,所以一个进程的平均性能只能在过去3个月内得到,比如说。
当由于性能或调试不好而出现异常值时,问题就出现了,进程在0秒内完成。
我想以某种方式自动消除任何异常值。
VAR()
或
STDEV()
聚合函数有效吗?