Re: 7.3.4 and 7.4 ORDER in queries - Mailing list pgsql-general

From Christopher Browne
Subject Re: 7.3.4 and 7.4 ORDER in queries
Date
Msg-id 60brqxlhwz.fsf@dev6.int.libertyrms.info
Whole thread Raw
In response to 7.3.4 and 7.4 ORDER in queries  (javier garcia - CEBAS <rn001@cebas.csic.es>)
List pgsql-general
rn001@cebas.csic.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)

pgsql-general by date:

Previous
From: "Philippe Lang"
Date:
Subject: Restore-point?
Next
From: Alexander Antonakakis
Date:
Subject: ip of the user doing an insert