Re: Clause accidentally pushed down ( Possible bug in Making Vars outer-join aware)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Clause accidentally pushed down ( Possible bug in Making Vars outer-join aware)
Date: 2023-05-17 15:28:52
Message-ID: 3344781.1684337332@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> On Wed, May 17, 2023 at 11:10 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> * I'm not terribly happy with 0004 as it stands, specifically the
>> business of making build_join_rel recalculate pushed_down_ojrelids
>> from scratch. Again, that's adding cycles to the mainline case to
>> support an unusual case. It'd be better to make
>> add_outer_joins_to_relids have an extra output that is the
>> pushed_down_ojrelids set, and pass that forward. I ran out of time
>> to make that happen today, though.

> Actually I did that in this way before I invented the join_info_array
> thing. See patch 'v2-0001-Adjust-outer-join-s-target-list.patch' in
> https://www.postgresql.org/message-id/CAMbWs49CB3txv_s3SwC1L2h1DiUPAn%2Bv0-O4UFfg33b%2BHXNnTg%40mail.gmail.com
> A little difference is that that patch makes add_outer_joins_to_relids
> collect pushed down joins rather than pushed down ojrelids, so that in
> build_joinrel_tlist we can just loop over pushed down joins rather than
> the whole join_info_list.

Ah, good idea. I made some cosmetic adjustments and pushed the lot.

We still have a couple of loose ends in this thread:

1. Do we need the change in add_nulling_relids that I postulated in [1]?

- bms_overlap(phv->phrels, context->target_relids))
+ bms_is_subset(phv->phrels, context->target_relids))

The test case that made that fall over no longer does so, but I'm
suspicious that this is still needed. I'm not quite sure though,
and I'm even less sure about the corresponding change in
remove_nulling_relids:

- !bms_overlap(phv->phrels, context->except_relids))
+ !bms_is_subset(phv->phrels, context->except_relids))

which I made up pretty much out of whole cloth.

2. Can we do anything to tighten make_outerjoininfo's computation of
potential commutator pairs, as I speculated in [2]? This isn't a bug
hazard anymore (I think), but adding useless bits there clearly does
cause us to waste cycles later. If we can tighten that cheaply, it
should be a win.

3. In general, it seems like what your fixes are doing is computing
transitive closures of the commute_above relationships. I wonder if
we can save anything by pre-calculating the closure sets. Again,
I don't want to add cycles in cases where the whole thing doesn't
apply, but maybe we'd not have to.

regards, tom lane

[1] https://www.postgresql.org/message-id/2489296.1684195396%40sss.pgh.pa.us
[2] https://www.postgresql.org/message-id/2766442.1684265014%40sss.pgh.pa.us

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Janes 2023-05-17 23:43:47 Re: Need Support to Upgrade from 13.6 to 15.3
Previous Message Alexander Lakhin 2023-05-17 14:00:00 Re: BUG #17884: gist_page_items() crashes for a non-leaf page of an index with non-key columns