diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-09-17 20:49:29 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-09-17 20:49:29 +0000 |
| commit | 488d70ab46311386801c10691196ec8d755f2283 (patch) | |
| tree | 043fc65616c8690113e2b5c18222bcd230197c9b /src/backend/optimizer/plan/createplan.c | |
| parent | e3f027115a5a5109527238886bde7f6d5b4a5b96 (diff) | |
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
Diffstat (limited to 'src/backend/optimizer/plan/createplan.c')
| -rw-r--r-- | src/backend/optimizer/plan/createplan.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index ac9b96229a1..0bb53d33089 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.262 2009/09/12 22:12:04 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.263 2009/09/17 20:49:29 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -164,6 +164,11 @@ create_plan(PlannerInfo *root, Path *best_path) case T_WorkTableScan: plan = create_scan_plan(root, best_path); break; + case T_Join: + /* this is only used for no-op joins */ + Assert(IsA(best_path, NoOpPath)); + plan = create_plan(root, ((NoOpPath *) best_path)->subpath); + break; case T_HashJoin: case T_MergeJoin: case T_NestLoop: |
