Fast path for empty relids in check_outerjoin_delay()

From: Richard Guo <riguo(at)pivotal(dot)io>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Fast path for empty relids in check_outerjoin_delay()
Date: 2018-12-12 07:32:09
Message-ID: CAN_9JTySXvSkisdRiWMxiZa09onKAF4uXwXsLRCtqXAWdRjp7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

Function check_outerjoin_delay() is used to detect whether a qual
referencing the given relids must be delayed in application due to the
presence of a lower outer join.

If the given relids are empty, we should be able to return from this
function via the same fast path as for the case that there is no special
joins, without going through all the remaining processing. Empty relids
can be very common in check_outerjoin_delay(). Think about the query
below:

select * from a left join (b left join c on true) on coalesce(b.i,1) =
1;

The qual 'coalesce(b.i,1) = 1' is detected as maybe_equivalence by
distribute_qual_to_rels(), because it doesn't reference any nonnullable
rels at the upper left join node (so it is is_pushed_down) and it
doesn't reference any nullable rels at the lower left join node as well
(so it is not-outerjoin_delayed). Before we treat it as an equivalence
clause, we will check that each side of the qual satisfies the
not-outerjoin_delayed condition on its own. For the right side, we will
check with empty relids in check_outerjoin_delay().

This small revise is not expected to bring performance improvements, but
can improve the readability of the code that for empty relids, the qual
is always considered as being not-outerjoin_delayed.

Is this code change worthwhile? Any thoughts?

Thanks
-Richard

Attachment Content-Type Size
Fast-path-for-empty-relids-in-check_outerjoin_delay-v1.patch application/octet-stream 566 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2018-12-12 08:03:02 Re: proposal: plpgsql pragma statement
Previous Message Laurenz Albe 2018-12-12 06:13:45 Re: Remove Deprecated Exclusive Backup Mode