Skip site navigation (1) Skip section navigation (2)

Re: BUG #1555: bug in GROUP BY?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Peter Cottingham <cottingh(at)rci(dot)rutgers(dot)edu>,pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1555: bug in GROUP BY?
Date: 2005-03-27 06:46:23
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Michael Fuhr <mike(at)fuhr(dot)org> writes:
> On Mon, Mar 21, 2005 at 07:20:04PM +0000, Peter Cottingham wrote:
>> Appears that the GROUP BY clause is not working correctly on new server
>> (GROUP BY should order the result set in ASCENDING order, NOT DESCENDING 
>> order.)  See below

> As far as I know, the SQL standards don't specify that GROUP BY is
> supposed to give a particular order.

> Somebody please correct me if I'm mistaken

You're not.  Peter is apparently accustomed to databases that only know
how to implement GROUP BY with a sort-and-uniq kind of implementation
... that would include Postgres from a few years ago ... but there is
no such requirement in the spec.

Current PG versions are likely to implement GROUP BY with a hashing
method, which will yield a completely unsorted output.  It is pure
coincidence that it happened to look like descending order in Peter's

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Stephan SzaboDate: 2005-03-27 07:02:37
Subject: Re: BUG #1555: bug in GROUP BY?
Previous:From: Matthew T. O'ConnorDate: 2005-03-27 06:24:07
Subject: Re: BUG #1567: can't hide password with pg_autovacuum

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group