Re: Sorting an aggregated column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David Witham" <davidw(at)unidial(dot)com(dot)au>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Sorting an aggregated column
Date: 2004-03-23 14:54:02
Message-ID: 20189.1080053642@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"David Witham" <davidw(at)unidial(dot)com(dot)au> writes:
> So I see that there is the extra sort above the sub-query that
> wouldn't be there using 7.4. Are you saying that the sort by survey
> after the sort by survey,question would potentially reorder the
> records initially sorted by survey,question?

Exactly. Most implementations of qsort() aren't "stable", which means
they might reorder equal keys in some random way. So to preserve the
sub-ordering on question, you need the upper sort to be skipped. The
7.4 planner is smart enough to notice it doesn't need the upper sort,
prior releases were not.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2004-03-23 16:17:31 Re: fine grained trigger time specification...
Previous Message Erik Thiele 2004-03-23 14:19:13 fine grained trigger time specification...