Re: Sorting an aggregated column - Mailing list pgsql-sql

From Tom Lane
Subject Re: Sorting an aggregated column
Date
Msg-id 20189.1080053642@sss.pgh.pa.us
Whole thread Raw
In response to Re: Sorting an aggregated column  ("David Witham" <davidw@unidial.com.au>)
List pgsql-sql
"David Witham" <davidw@unidial.com.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


pgsql-sql by date:

Previous
From: Erik Thiele
Date:
Subject: fine grained trigger time specification...
Next
From: Erik Thiele
Date:
Subject: Re: fine grained trigger time specification...