Re: Any better plan for this query?..

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Dimitri <dimitrik(dot)fr(at)gmail(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Dimitri Fontaine <dfontaine(at)hi-media(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Aidan Van Dyk <aidan(at)highrise(dot)ca>, Merlin Moncure <mmoncure(at)gmail(dot)com>, PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Any better plan for this query?..
Date: 2009-05-19 22:49:45
Message-ID: 19434.1242773385@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Simon Riggs <simon(at)2ndQuadrant(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Haas 2009-05-20 03:54:19 Re: Any better plan for this query?..
Previous Message Merlin Moncure 2009-05-19 21:48:49 Re: Any better plan for this query?..