Re: group by not returning sorted rows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bret Hughes <bhughes(at)elevating(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: group by not returning sorted rows
Date: 2004-04-05 22:34:21
Message-ID: 16211.1081204461@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bret Hughes <bhughes(at)elevating(dot)com> writes:
> and the rows resulting from the query are no longer sorted by log date.
> Is this a change since 7.2x?

Yes. 7.4 can use hashing instead of sorting to bring grouped rows
together.

> I can achieve the results I need by adding an order by clause identical
> to the group by but this seems counter intuitive since the rows have to
> be ordered anyway.

No they don't; you're making an assumption about the implementation that
is no longer warranted. The SQL spec doesn't require it either ...
output ordering is only guaranteed if you specify ORDER BY, per spec.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Eckermann 2004-04-05 22:34:42 Re: Question on pgsql trigger
Previous Message Jeff Eckermann 2004-04-05 22:33:02 Re: Entered data appears TWICE in table!!?