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 2A11ED1CCAD for ; Mon, 5 Apr 2004 22:53:23 +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 17098-09 for ; Mon, 5 Apr 2004 19:53:53 -0300 (ADT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id C06D8D1CCCA for ; Mon, 5 Apr 2004 19:53:20 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id AD156356D6; Mon, 5 Apr 2004 15:54:00 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id AB960356CE; Mon, 5 Apr 2004 15:54:00 -0700 (PDT) Date: Mon, 5 Apr 2004 15:54:00 -0700 (PDT) From: Stephan Szabo To: Bret Hughes Cc: pgsql-sql@postgresql.org Subject: Re: group by not returning sorted rows In-Reply-To: <1081202143.18380.117.camel@bretsony> Message-ID: <20040405154818.F18308@megazone.bigpanda.com> References: <1081202143.18380.117.camel@bretsony> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/27 X-Sequence-Number: 17402 On Mon, 5 Apr 2004, Bret Hughes wrote: > select cities.name as city, buildings.name as building, > pagename, > log_date , > sum(exhibition_count) as tot > from logrecords > join cities on (logrecords.city=cities.num) > join buildings on (logrecords.building=buildings.num) > where advertiser = 'Nielsens' and > log_date >= '01/01/2004' and > log_date <= '01/31/2004' > group by cities.name, buildings.name,pagename,log_date ; > > I have migrated a database from a redhat 7.3 box running > [bhughes@compaq3 reports]$ rpm -q postgresql > postgresql-7.2.3-5.73 > > To a redhat 9 box running : > [bhughes@compaq2 reports]$ rpm -q postgresql > postgresql-7.4.2-1PGDG > > and the rows resulting from the query are no longer sorted by log date. > Is this a change since 7.2x? Yes. > 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. They no longer need to always be pre-ordered in order to do the group by (this depends on plan).