Re: 8.4b1: Query returning results in different order to 8.3

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Ian Barwick <barwick(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: 8.4b1: Query returning results in different order to 8.3
Date: 2009-04-18 17:11:06
Message-ID: 49EA09AA.2040900@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ian Barwick wrote:
> Note I'm not sure whether this is a bug, or whether the assumption
> made for the original query (that the row order returned by the
> subquery would be carried over to the main part of the query) is
> incorrect but just happened to work as expected pre-8.4.

The latter. Without an ORDER BY (at the outermost level), the order of
the result is not well defined. Before 8.4, UNION was always performed
by a Sort + Unique, which explains why the output is always sorted in
previous releases. 8.4 knows how to perform it with a Hash Aggregate,
which doesn't yield sorted output. You can look at the EXPLAIN output to
see the difference.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2009-04-18 18:44:19 Re: 8.4b1: Query returning results in different order to 8.3
Previous Message Ian Barwick 2009-04-18 15:12:09 8.4b1: Query returning results in different order to 8.3