Re: Any better plan for this query?.. - Mailing list pgsql-performance

From Matthew Wakeling
Subject Re: Any better plan for this query?..
Date
Msg-id alpine.DEB.2.00.0905191159530.2341@aragorn.flymine.org
Whole thread Raw
In response to Re: Any better plan for this query?..  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: Any better plan for this query?..  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-performance
On Tue, 19 May 2009, Simon Riggs wrote:
> Both plans for this query show an IndexScan on a two column-index, with
> an Index Condition of equality on the leading column. The ORDER BY
> specifies a sort by the second index column, so the top-level Sort is
> superfluous in this case.
>
> My understanding is that we don't currently eliminate superfluous
> additional sorts of this kind. Now I know that is a hard subject, but it
> seems straightforward to consider interesting sort order equivalence
> when we have constant equality constraints.

Yes, Postgres has been missing the boat on this one for a while. +1 on
requesting this feature.

Speaking of avoiding large sorts, I'd like to push again for partial
sorts. This is the situation where an index provides data sorted by column
"a", and the query requests data sorted by "a, b". Currently, Postgres
sorts the entire data set, whereas it need only group each set of
identical "a" and sort each by "b".

Matthew

--
 Riker: Our memory pathways have become accustomed to your sensory input.
 Data:  I understand - I'm fond of you too, Commander. And you too Counsellor

pgsql-performance by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Any better plan for this query?..
Next
From: Simon Riggs
Date:
Subject: Re: Any better plan for this query?..