Re: Ordering in an aggregate -- points to paths - Mailing list pgsql-sql

From Julian Scarfe
Subject Re: Ordering in an aggregate -- points to paths
Date
Msg-id 039401c3335d$f94d1760$0600a8c0@Wilbur
Whole thread Raw
In response to Ordering in an aggregate -- points to paths  ("Julian Scarfe" <julian.scarfe@ntlworld.com>)
List pgsql-sql
From: "Tom Lane" <tgl@sss.pgh.pa.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 ;-)





pgsql-sql by date:

Previous
From: Emmanuel Engelhart
Date:
Subject: UNION & LIMIT & ORDER BY
Next
From: Bruno Wolff III
Date:
Subject: Re: date question