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