Re: Do AGGREGATES consistently use sort order? - Mailing list pgsql-general

From Tom Lane
Subject Re: Do AGGREGATES consistently use sort order?
Date
Msg-id 5661.1189120355@sss.pgh.pa.us
Whole thread Raw
In response to Re: Do AGGREGATES consistently use sort order?  (Chris Browne <cbbrowne@acm.org>)
List pgsql-general
Chris Browne <cbbrowne@acm.org> writes:
> stark@enterprisedb.com (Gregory Stark) writes:
>> In theory we can't promise anything about future versions of
>> Postgres but there are lots of people doing this already so if ever
>> this was lost there would probably be some new explicit way to
>> achieve the same thing.

> Is there not some risk that the query planner might choose to do
> hash-based accumulation could discard the subquery's ordering?

Hash aggregation doesn't change the order in which input rows are fed to
any one aggregate; it only results in nominally-independent aggregate
functions being computed in parallel.  If you tried to write an
aggregate function that had hidden private state and wasn't re-entrant,
it would likely fail under hash aggregation; but aggregate functions
that "play by the rules" by keeping all their state in the declared
state object will work fine.

The long and the short of it is that we are very well aware that people
depend on this behavior, and we are not likely to break it.

            regards, tom lane

pgsql-general by date:

Previous
From: brian
Date:
Subject: log_statement and PREPARE
Next
From: Chris Browne
Date:
Subject: Re: an other provokative question??