Обсуждение: pgsql: When removing a left join, clean out references in EquivalenceCl

Поиск
Список
Период
Сортировка

pgsql: When removing a left join, clean out references in EquivalenceCl

От
Tom Lane
Дата:
When removing a left join, clean out references in EquivalenceClasses.

Since commit b448f1c8d, we've been able to remove left joins
(that are otherwise removable) even when they are underneath
other left joins, a case that was previously prevented by a
delay_upper_joins check.  This is a clear improvement, but
it has a surprising side-effect: it's now possible that there
are EquivalenceClasses whose relid sets mention the removed
baserel and/or outer join.  If we fail to clean those up,
we may drop essential join quals due to not having any join
level that appears to satisfy their relid sets.

(It's not quite 100% clear that this was impossible before.
But the lack of complaints since we added join removal a dozen
years ago strongly suggests that it was impossible.)

Richard Guo and Tom Lane, per bug #17976 from Zuming Jiang

Discussion: https://postgr.es/m/17976-4b638b525e9a983b@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f4c00d138f6dea4c9d8af8ec280b7edc9b0a29e1

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c | 68 +++++++++++++++++++++++++++++++
src/test/regress/expected/join.out        | 31 ++++++++++++++
src/test/regress/sql/join.sql             | 23 +++++++++++
3 files changed, 122 insertions(+)