pgsql: Implement "join removal" for cases where the inner side of a left

Lists: pgsql-committers
From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Implement "join removal" for cases where the inner side of a left
Date: 2009-09-17 20:49:29
Message-ID: 20090917204929.6C38F753FB7@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

Log Message:
-----------
Implement "join removal" for cases where the inner side of a left join
is unique and is not referenced above the join. In this case the inner
side doesn't affect the query result and can be thrown away entirely.
Although perhaps nobody would ever write such a thing by hand, it's
a reasonably common case in machine-generated SQL.

The current implementation only recognizes the case where the inner side
is a simple relation with a unique index matching the query conditions.
This is enough for the use-cases that have been shown so far, but we
might want to try to handle other cases later.

Robert Haas, somewhat rewritten by Tom

Modified Files:
--------------
pgsql/src/backend/nodes:
outfuncs.c (r1.363 -> r1.364)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/outfuncs.c?r1=1.363&r2=1.364)
pgsql/src/backend/optimizer:
README (r1.50 -> r1.51)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/README?r1=1.50&r2=1.51)
pgsql/src/backend/optimizer/path:
allpaths.c (r1.185 -> r1.186)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/allpaths.c?r1=1.185&r2=1.186)
indxpath.c (r1.241 -> r1.242)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/indxpath.c?r1=1.241&r2=1.242)
joinpath.c (r1.123 -> r1.124)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/joinpath.c?r1=1.123&r2=1.124)
pgsql/src/backend/optimizer/plan:
createplan.c (r1.262 -> r1.263)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/createplan.c?r1=1.262&r2=1.263)
pgsql/src/backend/optimizer/util:
pathnode.c (r1.153 -> r1.154)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/util/pathnode.c?r1=1.153&r2=1.154)
pgsql/src/include/nodes:
nodes.h (r1.224 -> r1.225)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/nodes.h?r1=1.224&r2=1.225)
relation.h (r1.174 -> r1.175)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/relation.h?r1=1.174&r2=1.175)
pgsql/src/include/optimizer:
pathnode.h (r1.80 -> r1.81)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/pathnode.h?r1=1.80&r2=1.81)
paths.h (r1.107 -> r1.108)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/paths.h?r1=1.107&r2=1.108)