From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix mis-optimization of semijoins with more than one LHS relatio |
Date: | 2017-05-01 18:39:23 |
Message-ID: | E1d5GEF-0002m0-2w@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix mis-optimization of semijoins with more than one LHS relation.
The inner-unique patch (commit 9c7f5229a) supposed that if we're
considering a JOIN_UNIQUE_INNER join path, we can always set inner_unique
for the join, because the inner path produced by create_unique_path should
be unique relative to the outer relation. However, that's true only if
we're considering joining to the whole outer relation --- otherwise we may
be applying only some of the join quals, and so the inner path might be
non-unique from the perspective of this join. Adjust the test to only
believe that we can set inner_unique if we have the whole semijoin LHS on
the outer side.
There is more that can be done in this area, but this commit is only
intended to provide the minimal fix needed to get correct plans.
Per report from Teodor Sigaev. Thanks to David Rowley for preliminary
investigation.
Discussion: https://postgr.es/m/f994fc98-389f-4a46-d1bc-c42e05cb43ed@sigaev.ru
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/2057a58d1629ebffce694e3cef7f714571a88dd7
Modified Files
--------------
src/backend/optimizer/path/joinpath.c | 10 +++++++---
src/test/regress/expected/join.out | 29 +++++++++++++++++++++++++++++
src/test/regress/sql/join.sql | 8 ++++++++
3 files changed, 44 insertions(+), 3 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-05-01 18:53:51 | pgsql: Reduce semijoins with unique inner relations to plain inner join |
Previous Message | Peter Eisentraut | 2017-05-01 16:19:10 | pg_ctl wait exit code (was Re: [COMMITTERS] pgsql: Additional tests for subtransactions in recovery) |