I need to calculate the average duration of one of our running stored procedures. For example the duration(in seconds) of SP are: 1,30,2,5,2,15,35,7,3,4,2,1,2,40
I have to eliminate top 10% calls (fast calls) & bottom 10% calls (slow calls) & calculate the average on the rest.
Is there a better approach minimizing the performance hit since this has to done on a huge data set in a regular basis?
The approach I'm aware is:
Eliminate top 10% records using following query which results two values (1,1)
SELECT TOP 10 PERCENT WITH TIES value FROM #t order by value asc
bottom 10% gives (35,40),
SELECT TOP 10 PERCENT WITH TIES value FROM #t order by value desc
After eliminating those values(1,1,35 & 40) the average is going to be 7.