Re: Aggregate ORDER BY patch - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Aggregate ORDER BY patch
Date
Msg-id 200911131823.35677.andres@anarazel.de
Whole thread Raw
In response to Re: Aggregate ORDER BY patch  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Friday 13 November 2009 16:35:08 Tom Lane wrote:
> Greg Stark <gsstark@mit.edu> writes:
> > On Fri, Nov 13, 2009 at 7:54 AM, Heikki Linnakangas
> >
> > <heikki.linnakangas@enterprisedb.com> wrote:
> >> Andrew Gierth wrote:
> >>> Herewith a patch to implement agg(foo ORDER BY bar) with or without
> >>> DISTINCT, etc.
> >>
> >> What does that mean? Aggregate functions are supposed to be commutative,
> >> right?
> >
> > We certainly have non-commutative agggregates currently, notably
> > array_agg()
> 
> Right.  The fact that none of the standard aggregates are
> order-sensitive doesn't mean that it's not useful to have user-defined
> ones that are.  Currently we suggest fetching from an ordered sub-select
> if you want to use an aggregate that is input order sensitive.  This
> patch just provides an alternative (and equally nonstandard) notation
> for that.
> 
> I'm not entirely convinced that adding ORDER BY here is a good idea,
> partly because it goes so far beyond the spec and partly because it's
> not going to be easily optimizable.  But I can see that there is a
> use-case.
The spec supports the ORDER BY syntax for the xmlagg aggregate...

Andres


pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Check constraint on domain over an array not executed for array literals
Next
From: Bruce Momjian
Date:
Subject: Re: next CommitFest