X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3FF3CD1C9BE for ; Mon, 5 Apr 2004 22:33:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 15084-04 for ; Mon, 5 Apr 2004 19:34:14 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id BB6CCD1B974 for ; Mon, 5 Apr 2004 19:33:41 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i35MYL5D016212; Mon, 5 Apr 2004 18:34:21 -0400 (EDT) To: Bret Hughes Cc: pgsql-sql@postgresql.org Subject: Re: group by not returning sorted rows In-reply-to: <1081202143.18380.117.camel@bretsony> References: <1081202143.18380.117.camel@bretsony> Comments: In-reply-to Bret Hughes message dated "05 Apr 2004 16:55:42 -0500" Date: Mon, 05 Apr 2004 18:34:21 -0400 Message-ID: <16211.1081204461@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/29 X-Sequence-Number: 17404 Bret Hughes 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