Re: 7.3.4 and 7.4 ORDER in queries

From: Christopher Browne <cbbrowne(at)libertyrms(dot)info>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: 7.3.4 and 7.4 ORDER in queries
Date: 2003-11-27 19:39:56
Message-ID: 60brqxlhwz.fsf@dev6.int.libertyrms.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

rn001(at)cebas(dot)csic(dot)es (javier garcia - CEBAS) writes:
> I'm not an expert, not by far.
> I've just installed postgres7.4 and have realized tat the order of rows in
> queries in different to that in 7.3.4. It seems that previously it was more
> logic, ordering by the first column, then by the second,... by default.
> At least this is so in a couple of queries I have. And now I have to
> explicitly say the order I want.
>
> Could someone just tell me why is this so?

You always had to explicitly state ORDER BY if you wanted to get a
specific ordering; that's how SQL is designed.

There are a number of cases where earlier versions of PostgreSQL had
to perform specific sort procedures in order to perform GROUP BY
queries, whereas 7.4 is able to use unordered hash tables to collect
the data, thereby eliminating the sorts.

That is quite likely to be the sort of thing that you are observing.

If you want the data to be returned in a particular order, then you
MUST state that order, otherwise you'll get whatever the database
gives you, and yes, indeed, the ordering that is imposed implicitly
can and does change.
--
let name="cbbrowne" and tld="libertyrms.info" in String.concat "@" [name;tld];;
<http://dev6.int.libertyrms.com/>
Christopher Browne
(416) 646 3304 x124 (land)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Browne 2003-11-27 19:50:02 Re: 7.3.4 and 7.4 ORDER in queries
Previous Message Peter Eisentraut 2003-11-27 18:34:41 Re: 7.3.4 and 7.4 ORDER in queries