Re: Planner issue on sorting joining of two tables with limit

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Planner issue on sorting joining of two tables with limit
Date: 2010-05-16 12:21:37
Message-ID: AANLkTim_lnLPp_TX4_FHlSzs00K7jQUmsjeYTp8ZPpkR@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, May 7, 2010 at 11:35 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
>> Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:
>>>> I just don't find why it is coincidence. I think that such plan
>>>> will always produce result ordered by two columns, because such
>>>> nested index scan always produce this result.
>
>> Assuming a nested index scan, or any particular plan, is unwise.
>
> I think he's proposing that the planner should recognize that a plan
> of this type produces a result sorted by the additional index columns.
> I'm not convinced either that the sortedness property really holds,
> or that it would be worth the extra planning effort to check for;
> but it's not a fundamentally misguided proposal.

I took a slightly different point - a nested loop will be ordered by
the ordering of the outer side and then, within that, the ordering of
the inner side, presuming (not quite sure how to phrase this) that the
outer side is "unique enough" with respect to the ordering. I'm not
too sure whether there's anything useful we can do with this
information in a reasonable number of CPU cycles, but it is something
I've noticed before while reading the code.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jayadevan M 2010-05-17 05:04:29 pg_dump and pg_restore
Previous Message joao.pinheiro 2010-05-15 20:41:44 Re: Benchmark with FreeBSD 8.0 and pgbench