Re: WITHIN GROUP patch - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: WITHIN GROUP patch
Date
Msg-id 87k3fkifry.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: WITHIN GROUP patch  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: WITHIN GROUP patch
List pgsql-hackers
>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
Tom> Well, okay, but you've not said anything that wouldn't beTom> handled just as well by some logic that adds a
fixedTom>integer-constant-zero flag column to the rows going into theTom> tuplesort.
 

Adding such a column unconditionally even for non-hypothetical
functions would break the optimization for sorting a single column
(which is a big deal, something like 3x speed difference, for by-value
types).

Adding it only for hypothetical set functions is making a distinction
in how functions are executed that I don't think is warranted -
imagine for example a function that calculates some measure over a
frequency distribution by adding a known set of boundary values to the
sort; this would not be a hypothetical set function in terms of
argument processing, but it would still benefit from the extra sort
column. I did not want to unnecessarily restrict such possibilities.
>> It would still be overloaded in some sense because a non-hypothetical>> ordered set function could still take an
arbitrarynumber of args>> (using variadic "any") - there aren't any provided, but there's no>> good reason to disallow
user-definedfunctions doing that - so you'd>> still need a special value like -1 for aggordnargs to handle that.
 
Tom> Sure.  But a -1 to indicate "not applicable" doesn't seem like it'sTom> too much of a stretch.  It's the -2
businessthat's bothering me.Tom> Again, that seems unnecessarily non-orthogonal --- who's to say whichTom> functions
wouldwant to constrain the number of direct arguments andTom> which wouldn't?  (I wonder whether having this info in
thecatalogsTom> isn't the wrong thing anyhow, as opposed to expecting the functionsTom> themselves to check the
argumentcount at runtime.)
 

Not checking the number of arguments to a function until runtime seems
a bit on the perverse side. Having a fixed number of direct args is
the "normal" case (as seen from the fact that all the non-hypothetical
ordered set functions in the spec and in our patch have fixed argument
counts).

-- 
Andrew (irc:RhodiumToad)



pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Why we are going to have to go DirectIO
Next
From: David Fetter
Date:
Subject: Re: Status of FDW pushdowns