diff --git a/src/gausskernel/optimizer/util/pruning.cpp b/src/gausskernel/optimizer/util/pruning.cpp index 5f977aba3..be8a3bf4c 100644 --- a/src/gausskernel/optimizer/util/pruning.cpp +++ b/src/gausskernel/optimizer/util/pruning.cpp @@ -76,6 +76,8 @@ static PruningResult* partitionEqualPruningWalker(PartitionType partType, Expr* ((pruningResult)->boundary->partitionKeyNum > 1 && (topValue) && PointerIsValid((topValue)[0]) && \ !(pruningResult)->boundary->maxClose[0]) +#define IF_OPEN_PARTITION_PRUNING 0 + static PartitionMap* GetRelPartitionMap(Relation relation) { return relation->partMap; @@ -630,18 +632,17 @@ PruningResult* partitionPruningForExpr(PlannerInfo* root, RangeTblEntry* rte, Re else result = partitionPruningWalker(expr, context); if (result->exprPart != NULL || result->paramArg != NULL) { -#ifndef ENABLE_MULTIPLE_NODES - destroyPruningResult(result); - result = getFullPruningResult(rel); - return result; -#else + if (!IF_OPEN_PARTITION_PRUNING) { + destroyPruningResult(result); + result = getFullPruningResult(rel); + return result; + } Param* paramArg = (Param *)copyObject(result->paramArg); destroyPruningResult(result); result = getFullPruningResult(rel); result->expr = expr; result->paramArg = paramArg; return result; -#endif } /* Never happen, just to be self-contained */ if (!PointerIsValid(result)) { diff --git a/src/gausskernel/runtime/executor/execMain.cpp b/src/gausskernel/runtime/executor/execMain.cpp index 6461dc155..8e80e3536 100644 --- a/src/gausskernel/runtime/executor/execMain.cpp +++ b/src/gausskernel/runtime/executor/execMain.cpp @@ -1448,6 +1448,10 @@ void InitPlan(QueryDesc *queryDesc, int eflags) } planstate = ExecInitNode(plan, estate, eflags); + if (estate->pruningResult) { + destroyPruningResult(estate->pruningResult); + estate->pruningResult = NULL; + } /* * Get the tuple descriptor describing the type of tuples to return. */ diff --git a/src/gausskernel/runtime/executor/execUtils.cpp b/src/gausskernel/runtime/executor/execUtils.cpp index 8c5a00437..3cfb5421a 100644 --- a/src/gausskernel/runtime/executor/execUtils.cpp +++ b/src/gausskernel/runtime/executor/execUtils.cpp @@ -170,6 +170,8 @@ EState* CreateExecutorState(void) estate->es_material_of_subplan = NIL; estate->es_recursive_next_iteration = false; + estate->pruningResult = NULL; + /* * Return the executor state structure */ diff --git a/src/gausskernel/runtime/executor/nodeBitmapHeapscan.cpp b/src/gausskernel/runtime/executor/nodeBitmapHeapscan.cpp index 76d3770a0..e7929c85a 100644 --- a/src/gausskernel/runtime/executor/nodeBitmapHeapscan.cpp +++ b/src/gausskernel/runtime/executor/nodeBitmapHeapscan.cpp @@ -786,6 +786,10 @@ static void ExecInitPartitionForBitmapHeapScan(BitmapHeapScanState* scanstate, E PruningResult* resultPlan = NULL; if (plan->scan.pruningInfo->expr) { resultPlan = GetPartitionInfo(plan->scan.pruningInfo, estate, currentRelation); + if (estate->pruningResult) { + destroyPruningResult(estate->pruningResult); + } + estate->pruningResult = resultPlan; } else { resultPlan = plan->scan.pruningInfo; } diff --git a/src/gausskernel/runtime/executor/nodeBitmapIndexscan.cpp b/src/gausskernel/runtime/executor/nodeBitmapIndexscan.cpp index 320822449..be923fd13 100644 --- a/src/gausskernel/runtime/executor/nodeBitmapIndexscan.cpp +++ b/src/gausskernel/runtime/executor/nodeBitmapIndexscan.cpp @@ -491,7 +491,13 @@ void ExecInitPartitionForBitmapIndexScan(BitmapIndexScanState* indexstate, EStat indexstate->lockMode = lock; PruningResult* resultPlan = NULL; if (plan->scan.pruningInfo->expr) { - resultPlan = GetPartitionInfo(plan->scan.pruningInfo, estate, rel); + if (estate->pruningResult) { + resultPlan = estate->pruningResult; + } else { + resultPlan = GetPartitionInfo(plan->scan.pruningInfo, estate, rel); + destroyPruningResult(estate->pruningResult); + estate->pruningResult = resultPlan; + } } else { resultPlan = plan->scan.pruningInfo; } diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index b512cd095..a70cc41ce 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -573,6 +573,8 @@ typedef struct EState { #ifdef ENABLE_MOT JitExec::JitContext* mot_jit_context; /* MOT JIT context required for executing LLVM jitted code */ #endif + + PruningResult* pruningResult; } EState; /*