Re: Aggregates with non-commutative transition functions - Mailing list pgsql-general

From Tom Lane
Subject Re: Aggregates with non-commutative transition functions
Date
Msg-id 16193.1045323727@sss.pgh.pa.us
Whole thread Raw
In response to Re: Aggregates with non-commutative transition functions  (Emmanuel Charpentier <charpent@bacbuc.dyndns.org>)
Responses Re: Aggregates with non-commutative transition functions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Emmanuel Charpentier <charpent@bacbuc.dyndns.org> writes:
> Since the stability of the sort is an issue but for this quite specific
> case, one could envision a flag to "CREATE AGGREGATE", signalling the
> planner the fact that the transition function isn't commutative, hence the
> need to use a stable version of sort()

Actually, I would think that you'd really prefer that the system not
run a sort step at all.

As of CVS tip, if the planner decides to use hash-based aggregation
for your query then there wouldn't be any pre-sort.  But there's no
guarantee it will do that.

A better alternative is to get the planner to notice in the context of
the outer query that the inner query's result is already sorted by
recnum.  Then it wouldn't do the unwanted sort in any case.  This has
been on the to-do list for awhile, but hasn't risen to the top ...

            regards, tom lane

pgsql-general by date:

Previous
From: Ezra
Date:
Subject: Does postgres have something similiar to the LOAD DATA INFILE
Next
From: Tom Lane
Date:
Subject: Re: In 7.3.1, will I be able to reindex toast?