----------------------------------------- install ------------
create or replace function r_median(_float8) returns float as '
median(arg1)
' language 'plr';
CREATE AGGREGATE median (
sfunc = plr_array_accum,
basetype = float8,
stype = _float8,
finalfunc = r_median
);
----------------------------------------- test ---------------
select max(a.res),avg(a.res),median(a.res),min(a.res)
from
( select (st_area(wkb_geometry) - shape_area) as res
from landtypes_090911_marin_parcel_adjusted) a;
thuban1 Time: 21255 ms
r900 Time: 13880 ms
ps Time: 9337 ms
macpro Time: 8856 ms
i7-960+ Time: 6980 ms
ps- add standard deviation sd too
pps- just noticed this post