1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-14 08:21:07 +03:00

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
This commit is contained in:
Tom Lane
2009-09-17 20:49:29 +00:00
parent e3f027115a
commit 488d70ab46
11 changed files with 349 additions and 11 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.185 2009/09/02 17:52:24 tgl Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.186 2009/09/17 20:49:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1387,6 +1387,10 @@ print_path(PlannerInfo *root, Path *path, int indent)
ptype = "Unique";
subpath = ((UniquePath *) path)->subpath;
break;
case T_NoOpPath:
ptype = "NoOp";
subpath = ((NoOpPath *) path)->subpath;
break;
case T_NestPath:
ptype = "NestLoop";
join = true;