agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Fix more duplicate qual clauses in parameterized paths 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix more duplicate qual clauses in parameterized paths @ 2026-09-10 01:04 Richard Guo <rguo@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Richard Guo @ 2026-09-10 01:04 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix more duplicate qual clauses in parameterized paths Commit f836b688f ensured that at most one clone of a join clause is chosen for a parameterized path, so long as the clone variants are parse-tree distinct. Two ways remained to end up enforcing the same condition more than once, which wastes execution effort and applies the clause's selectivity multiple times, underestimating the row count. If a commuting outer join nulls no Var referenced by a particular qual, the clone variants of that qual are parse-tree identical, and the incompatible_relids test cannot tell them apart. To fix, enforce just the first surviving variant, identified by rinfo_serial. The other case is in get_joinrel_parampathinfo, where the clause-recovery pass for dropped EquivalenceClasses queries the EC machinery with a context that overlaps the preceding loop's, so the derived-clause cache can hand back a clause that that loop already accepted. To fix, skip any clause that is already present in the collected list. Also add assertions verifying that the clauses to be enforced at a join or within a parameterized path contain no duplicate rinfo_serial, to catch any remaining or future violations. These assertions are added in master only, since hard prevention of duplicate clauses is a new goal and other unfixed cases may remain. Back-patch to v19, as with commit f836b688f. Author: Richard Guo <guofenglinux@gmail.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAMbWs4_Ezb1Lnj7BqcTQSysC6B5UFZxfhib8xr6rqpu5uqr8dA@mail.gmail.com Backpatch-through: 19 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/8510bcc981bd4bba06fd2c038dab7cc15887b51e Modified Files -------------- src/backend/optimizer/util/relnode.c | 146 +++++++++++++++++++++++++---------- src/test/regress/expected/join.out | 55 +++++++++++++ src/test/regress/sql/join.sql | 22 ++++++ 3 files changed, 183 insertions(+), 40 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix more duplicate qual clauses in parameterized paths @ 2026-09-10 01:04 Richard Guo <rguo@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Richard Guo @ 2026-09-10 01:04 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix more duplicate qual clauses in parameterized paths Commit f836b688f ensured that at most one clone of a join clause is chosen for a parameterized path, so long as the clone variants are parse-tree distinct. Two ways remained to end up enforcing the same condition more than once, which wastes execution effort and applies the clause's selectivity multiple times, underestimating the row count. If a commuting outer join nulls no Var referenced by a particular qual, the clone variants of that qual are parse-tree identical, and the incompatible_relids test cannot tell them apart. To fix, enforce just the first surviving variant, identified by rinfo_serial. The other case is in get_joinrel_parampathinfo, where the clause-recovery pass for dropped EquivalenceClasses queries the EC machinery with a context that overlaps the preceding loop's, so the derived-clause cache can hand back a clause that that loop already accepted. To fix, skip any clause that is already present in the collected list. Also add assertions verifying that the clauses to be enforced at a join or within a parameterized path contain no duplicate rinfo_serial, to catch any remaining or future violations. These assertions are added in master only, since hard prevention of duplicate clauses is a new goal and other unfixed cases may remain. Back-patch to v19, as with commit f836b688f. Author: Richard Guo <guofenglinux@gmail.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAMbWs4_Ezb1Lnj7BqcTQSysC6B5UFZxfhib8xr6rqpu5uqr8dA@mail.gmail.com Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/be2602cfcc1578480ccefca66eda93975d2c10de Modified Files -------------- src/backend/optimizer/util/relnode.c | 115 ++++++++++++++++++++++------------- src/test/regress/expected/join.out | 55 +++++++++++++++++ src/test/regress/sql/join.sql | 22 +++++++ 3 files changed, 151 insertions(+), 41 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-09-10 01:04 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-09-10 01:04 pgsql: Fix more duplicate qual clauses in parameterized paths Richard Guo <rguo@postgresql.org> 2026-09-10 01:04 pgsql: Fix more duplicate qual clauses in parameterized paths Richard Guo <rguo@postgresql.org>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox