>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
Tom> I've committed this after significant editorialization --- mostTom> notably, I pushed control of the sort step
intothe aggregateTom> support functions.
Initial tests suggest that your version is ~40% slower than ours on
some workloads.
On my system, this query takes ~950ms using our dev branch of the code,
and ~1050ms on git master (using \timing in psql for timings, and taking
the best of many consecutive runs):
select count(*) from (select percentile_disc(0.5) within group (order by i) from generate_series(1,3) i,
generate_series(1,100000)j group by j) s;
About ~700ms of that is overhead, as tested by running this query with
enable_hashagg=false:
select count(*) from (select j from generate_series(1,3) i, generate_series(1,100000) j group by j) s;
So your version is taking 350ms for the percentile calculations
compared to 250ms for ours.
--
Andrew (irc:RhodiumToad)