diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-02-05 02:59:17 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-02-05 02:59:17 +0000 |
commit | 336a6491aaa8a2ba9a3118285522f237806b5e37 (patch) | |
tree | 8c7313483667dd002728fdc2243d088adf56f5a8 /src/backend/optimizer/plan/setrefs.c | |
parent | 354213c7f493596448ca83f13d107a8ef7a08aae (diff) |
Improve my initial, rather hacky implementation of joins to append
relations: fix the executor so that we can have an Append plan on the
inside of a nestloop and still pass down outer index keys to index scans
within the Append, then generate such plans as if they were regular
inner indexscans. This avoids the need to evaluate the outer relation
multiple times.
Diffstat (limited to 'src/backend/optimizer/plan/setrefs.c')
-rw-r--r-- | src/backend/optimizer/plan/setrefs.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index 5a716ead476..56be7ea149b 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.119 2005/11/26 22:14:57 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.120 2006/02/05 02:59:16 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -769,8 +769,9 @@ set_join_references(Join *join, List *rtable) * Handle join references appearing in an inner indexscan's quals * * To handle bitmap-scan plan trees, we have to be able to recurse down - * to the bottom BitmapIndexScan nodes, so this is split out as a separate - * function. + * to the bottom BitmapIndexScan nodes; likewise, appendrel indexscans + * require recursing through Append nodes. This is split out as a separate + * function so that it can recurse. */ static void set_inner_join_references(Plan *inner_plan, @@ -910,6 +911,22 @@ set_inner_join_references(Plan *inner_plan, outer_itlist); } } + else if (IsA(inner_plan, Append)) + { + /* + * The inner side is an append plan. Recurse to see if it contains + * indexscans that need to be fixed. + */ + Append *appendplan = (Append *) inner_plan; + ListCell *l; + + foreach(l, appendplan->appendplans) + { + set_inner_join_references((Plan *) lfirst(l), + rtable, + outer_itlist); + } + } else if (IsA(inner_plan, TidScan)) { TidScan *innerscan = (TidScan *) inner_plan; |