Re: A problem in deconstruct_distribute_oj_quals

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: A problem in deconstruct_distribute_oj_quals
Дата
Msg-id 3027458.1675750371@sss.pgh.pa.us
обсуждение исходный текст
Ответ на A problem in deconstruct_distribute_oj_quals  (Richard Guo <guofenglinux@gmail.com>)
Ответы Re: A problem in deconstruct_distribute_oj_quals  (Richard Guo <guofenglinux@gmail.com>)
Список pgsql-hackers
Richard Guo <guofenglinux@gmail.com> writes:
> In deconstruct_distribute_oj_quals, when we've identified a commutable
> left join which provides join clause with flexible semantics, we try to
> generate multiple versions of the join clause.  Here we have the logic
> that puts back any ojrelids that were removed from its min_righthand.

>      /*
>       * Put any OJ relids that were removed from min_righthand back into
>       * ojscope, else distribute_qual_to_rels will complain.
>       */
>      ojscope = bms_join(ojscope, bms_intersect(sjinfo->commute_below,
>                                                sjinfo->syn_righthand));

> I doubt this is necessary.  It seems to me that all relids mentioned
> within the join clause have already been contained in ojscope, which is
> the union of min_lefthand and min_righthand.

Hmm ... that was needed at some point in the development of that
function, but maybe it isn't as the code stands now.  It does look
like the "this_ojscope" manipulations within the loop cover this.

> I noticed this code because I came across a problem with a query as
> below.

> create table t (a int);

> select t1.a from (t t1 left join t t2 on true) left join (t t3 left join t
> t4 on t3.a = t4.a) on t2.a = t3.a;

> When we deal with qual 't2.a = t3.a', deconstruct_distribute_oj_quals
> would always add the OJ relid of t3/t4 into its required_relids, due to
> the code above, which I think is wrong.  The direct consequence is that
> we would miss the plan that joins t2 and t3 directly.

I don't see any change in this query plan when I remove that code, so
I'm not sure you're explaining your point very well.

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Nikita Malakhov
Дата:
Сообщение: Re: [PATCH] Compression dictionaries for JSONB
Следующее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Make mesage at end-of-recovery less scary.