>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
>> Updated version of the aggregate order by patch.
Tom> I'm starting to look at this now. I find it rather bizarre toTom> merge both the actual arguments of an aggregate
andthe optionalTom> ORDER BY expressions into a single targetlist. It doesn't seemTom> like that would be an
especiallyconvenient representation toTom> work with,
It's extremely convenient, since you need the arguments and the
ordering expressions together in a slot in order to feed them to
tuplesort (in the general case where there is more than one
expression); you need a tupledesc to pass to tuplesort; and there are
existing functions to construct all of these things from the tlist.
Also, you want to merge the argument expressions and ordering
expressions where possible, and this is exactly what the existing
transformSortClause stuff expects.
Tom> and I would also expect there to be a nonzero performance hitTom> from the extra TargetEntry expression nodes,
evenwhen theTom> feature is not in use.
I tested for that and couldn't reliably detect any (certainly <2%
on count(i) on generated data, and under the circumstances I was
testing that's not necessarily outside the error margin).
--
Andrew (irc:RhodiumToad)