Re: Removing INNER JOINs

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, Mart Kelder <mart(at)kelder31(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com>
Subject: Re: Removing INNER JOINs
Date: 2015-01-13 11:02:48
Message-ID: CAApHDvpYwin+1Zheq2vZ-ukEaZ0NO6R4dDo08OPjAKScO2z41w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 13 January 2015 at 11:29, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com> wrote:

> On 12/3/14 1:08 PM, Tom Lane wrote:
>
>> Heikki Linnakangas<hlinnakangas(at)vmware(dot)com> writes:
>>
>>> >Do you need to plan for every combination, where some joins are removed
>>> >and some are not?
>>>
>> I would vote for just having two plans and one switch node. To exploit
>> any finer grain, we'd have to have infrastructure that would let us figure
>> out*which* constraints pending triggers might indicate transient
>> invalidity of, and that doesn't seem likely to be worth the trouble.
>>
>
> In the interest of keeping the first pass simple... what if there was
> simply a switch node in front of every join that could be removable? That
> means you'd still be stuck with the overall plan you got from not removing
> anything, but simply eliminating the access to the relation(s) might be a
> big win in many cases, and presumably this would be a lot easier to code.

I can't quite get my head around what you mean here, as the idea sounds
quite similar to something that's been discussed already and ruled out.
If we're joining relation a to relation b, say the plan chosen is a merge
join. If we put some special node as the parent of the merge join then how
will we know to skip or not skip any sorts that are there especially for
the merge join, or perhaps the planner choose an index scan as a sorted
path, where now that the join is removed, could become a faster seqscan.
The whole plan switching node discussion came from this exact problem.
Nobody seemed to like the non-optimal plan that was not properly optimised
for having the relation removed.

It also seems that transitioning through needless nodes comes at a cost.
This is why I quite liked the Alternative Plan node idea, as it allowed me
to skip over the alternative plan node at plan initialisation.

Regards

David Rowley

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-01-13 11:09:03 Re: Unused variables in hstore_to_jsonb
Previous Message Vladimir Borodin 2015-01-13 10:11:22 Re: Check that streaming replica received all data after master shutdown