From 947bffb934b1749f309e219182614be371991f1b Mon Sep 17 00:00:00 2001 From: Zhang Mingli Date: Tue, 8 Aug 2023 16:02:22 +0800 Subject: [PATCH] Fix Bitmap Index Scan locus is NULL create_bitmap_subplan() will try to convert subplan to a bitmap indexscan, add locus info for that. QUERY PLAN -------------------------------------------- Gather Motion 6:1 (slice1; segments: 6) Locus: Entry -> Parallel Bitmap Heap Scan on t1 Locus: HashedWorkers Parallel Workers: 2 -> Bitmap Index Scan on t1_c2_idx Locus: Hashed It's reasonable to eliminate Parallel Workers info. Because a Bitmap Index Scan under Parallel Bitmap Heap Scan will only be taken by one procress as the Postgres Doc: In a parallel bitmap heap scan, one process is chosen as the leader. That process performs a scan of one or more indexes and builds a bitmap indicating which table blocks need to be visited. These blocks are then divided among the cooperating processes as in a parallel sequential scan. In other words, the heap scan is performed in parallel, but the underlying index scan is not. Authored-by: Zhang Mingli avamingli@gmail.com --- src/backend/optimizer/plan/createplan.c | 1 + src/test/regress/expected/gp_parallel.out | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 1904d143f4c..4e159562ce0 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -4194,6 +4194,7 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, plan->plan_width = 0; /* meaningless */ plan->parallel_aware = false; plan->parallel_safe = ipath->path.parallel_safe; + plan->locustype = ipath->path.locus.locustype; /* Extract original index clauses, actual index quals, relevant ECs */ subquals = NIL; subindexquals = NIL; diff --git a/src/test/regress/expected/gp_parallel.out b/src/test/regress/expected/gp_parallel.out index 23bba396d3d..e80fe8a0f54 100644 --- a/src/test/regress/expected/gp_parallel.out +++ b/src/test/regress/expected/gp_parallel.out @@ -224,7 +224,7 @@ explain(locus, costs off) select c2 from t1; Locus: HashedWorkers Parallel Workers: 2 -> Bitmap Index Scan on t1_c2_idx - Locus: NULL + Locus: Hashed Optimizer: Postgres query optimizer (8 rows) @@ -243,7 +243,7 @@ explain(locus, costs off) select count(c2) from t1; Locus: HashedWorkers Parallel Workers: 2 -> Bitmap Index Scan on t1_c2_idx - Locus: NULL + Locus: Hashed Optimizer: Postgres query optimizer (13 rows) @@ -266,7 +266,7 @@ explain(locus, costs off) select count(c2) from t1; -> Bitmap Heap Scan on t1 Locus: Hashed -> Bitmap Index Scan on t1_c2_idx - Locus: NULL + Locus: Hashed Optimizer: Postgres query optimizer (11 rows)