From bc843d396032acb75abfbcfab1a0c3b0b252c3f1 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 22 Apr 2005 21:58:32 +0000 Subject: First cut at planner support for bitmap index scans. Lots to do yet, but the code is basically working. Along the way, rewrite the entire approach to processing OR index conditions, and make it work in join cases for the first time ever. orindxpath.c is now basically obsolete, but I left it in for the time being to allow easy comparison testing against the old implementation. --- src/backend/optimizer/plan/createplan.c | 47 ++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src/backend/optimizer/plan/createplan.c') diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index faaf727da0d..e7a695e5725 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.182 2005/04/21 19:18:12 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.183 2005/04/22 21:58:31 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -870,6 +870,9 @@ create_bitmap_scan_plan(Query *root, /* Also extract the true index conditions */ indexquals = create_bitmap_indxqual(best_path->bitmapqual); + /* Reduce RestrictInfo list to bare expressions */ + scan_clauses = get_actual_clauses(scan_clauses); + /* * If this is a innerjoin scan, the indexclauses will contain join * clauses that are not present in scan_clauses (since the passed-in @@ -881,16 +884,9 @@ create_bitmap_scan_plan(Query *root, */ if (best_path->isjoininner) { - /* - * Pointer comparison should be enough to determine RestrictInfo - * matches. - */ - scan_clauses = list_union_ptr(scan_clauses, bitmapqualorig); + scan_clauses = list_union(scan_clauses, bitmapqualorig); } - /* Reduce RestrictInfo list to bare expressions */ - scan_clauses = get_actual_clauses(scan_clauses); - /* * The qpqual list must contain all restrictions not automatically * handled by the index. All the predicates in the indexquals will be @@ -1322,7 +1318,38 @@ create_nestloop_plan(Query *root, select_nonredundant_join_clauses(root, joinrestrictclauses, linitial(indexclauses), - best_path->jointype); + IS_OUTER_JOIN(best_path->jointype)); + } + } + else if (IsA(best_path->innerjoinpath, BitmapHeapPath)) + { + /* + * Same deal for bitmapped index scans. + */ + BitmapHeapPath *innerpath = (BitmapHeapPath *) best_path->innerjoinpath; + + if (innerpath->isjoininner) + { + List *bitmapquals; + List *bitmapclauses; + ListCell *l; + + bitmapquals = create_bitmap_qual(innerpath->bitmapqual); + + /* must convert qual list to restrictinfos ... painful ... */ + bitmapclauses = NIL; + foreach(l, bitmapquals) + { + bitmapclauses = lappend(bitmapclauses, + make_restrictinfo((Expr *) lfirst(l), + true, true)); + } + + joinrestrictclauses = + select_nonredundant_join_clauses(root, + joinrestrictclauses, + bitmapclauses, + IS_OUTER_JOIN(best_path->jointype)); } } -- cgit v1.2.3