From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Witham <davidw@unidial.com.au>
Cc: pgsql-sql@postgresql.org
Subject: Re: Sorting an aggregated column
Date: Tue, 23 Mar 2004 09:54:02 -0500
Message-ID: <20189.1080053642@sss.pgh.pa.us> (raw)
In-Reply-To: <CFA248776934FD43847E740E43C346D199DCAC@ozimelb03.ozicom.com>
References: <CFA248776934FD43847E740E43C346D199DCAC@ozimelb03.ozicom.com>
"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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, davidw@unidial.com.au
Subject: Re: Sorting an aggregated column
In-Reply-To: <20189.1080053642@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox