Re: Ordering in an aggregate -- points to paths

From: "Julian Scarfe" <julian(at)avbrief(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Ordering in an aggregate -- points to paths
Date: 2003-06-15 16:48:40
Message-ID: 039401c3335d$f94d1760$0600a8c0@Wilbur
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>

> Yeah, this is a fairly obvious thing to want to do with a user-written
> aggregate. It does not work in released versions, because the planner
> does not notice that the inner SELECT's output ordering matches what
> the GROUP BY needs, and so it inserts an additional Sort plan step
> above the sub-select (you can see this if you look at EXPLAIN output).
> Unfortunately, on most platforms qsort() isn't stable and will not
> preserve the ordering of its input for equal keys. So you lose the
> minor ordering by seq_no in the re-sort.

Most grateful for the rapid response Tom. Knowing that, I can work around by
iterating through the firs at the application level.

Regards

Julian Scarfe

PS: you shouldn't be working on a Sunday, it's bad for you ;-)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message David Pradier 2003-06-16 07:27:40 Re: How to make a IN without a table... ?
Previous Message Tom Lane 2003-06-15 15:49:57 Re: Ordering in an aggregate -- points to paths