Re: Poor performance on 9.4.4 when matching multiple columns from left side of LATERAL join

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Poor performance on 9.4.4 when matching multiple columns from left side of LATERAL join
Дата
Msg-id 10194.1447521551@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Poor performance on 9.4.4 when matching multiple columns from left side of LATERAL join  (Steven Grimm <sgrimm@thesegovia.com>)
Список pgsql-general
Steven Grimm <sgrimm@thesegovia.com> writes:
> It is puzzling that if, as suggested by someone else in the thread, I
> expand IN(a,b,c) to (x = a OR x = b OR x = c) it gets substantially
> faster, though still obviously falls afoul of the problem you describe
> above (~4 seconds instead of ~6 seconds). Should those two be equivalent?

The parser actually will do that expansion for you, when the IN-list items
contain variables ... but its definition of "variable" for this purpose is
"contain_vars_of_level(expr, 0)" so the outer-level Vars you've got in
this LATERAL subquery formulation don't trigger that behavior.  I seem to
remember writing it that way intentionally, but this example makes me
think maybe excluding outer-level Vars wasn't such a hot idea.  It will
remain a ScalarArrayOpExpr even if the query later gets flattened to the
point where the Vars aren't outer-level anymore, which is probably not
what we want it to be.

            regards, tom lane


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

Предыдущее
От: Steven Grimm
Дата:
Сообщение: Re: Poor performance on 9.4.4 when matching multiple columns from left side of LATERAL join
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: fast refresh materialized view