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

From Tom Lane
Subject Re: Any better plan for this query?..
Date
Msg-id 19434.1242773385@sss.pgh.pa.us
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?..  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-performance
Simon Riggs <simon@2ndQuadrant.com> writes:
> On Tue, 2009-05-19 at 08:58 -0400, Tom Lane wrote:
>> Nonsense.  The planner might think some other plan is cheaper, but
>> it definitely knows how to do this, and has since at least 8.1.

> Please look at Dimitri's plan. If it can remove the pointless sort, why
> does it not do so?

I haven't followed the whole thread, but the plan in the original post
is for a hash join.  The planner does not trust a hash join to preserve
the order of its left input, because of possible batching.  See the
discussion a couple of months ago where we considered allowing the
planner to disable batching so it *could* assume order preservation, and
decided the risk of hashtable bloat was too great.

            regards, tom lane

pgsql-performance by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: Any better plan for this query?..
Next
From: Robert Haas
Date:
Subject: Re: Any better plan for this query?..