diff --git a/src/backend/distributed/executor/adaptive_executor.c b/src/backend/distributed/executor/adaptive_executor.c index 330f2a410..c79ef0f18 100644 --- a/src/backend/distributed/executor/adaptive_executor.c +++ b/src/backend/distributed/executor/adaptive_executor.c @@ -961,11 +961,8 @@ ExecuteTaskListExtended(RowModifyLevel modLevel, List *taskList, if (localExecutionSupported && ShouldExecuteTasksLocally(taskList)) { bool readOnlyPlan = false; - - /* set local (if any) & remote tasks */ ExtractLocalAndRemoteTasks(readOnlyPlan, taskList, &localTaskList, &remoteTaskList); - locallyProcessedRows += ExecuteLocalTaskList(localTaskList, tupleStore); } else { @@ -983,6 +980,8 @@ ExecuteTaskListExtended(RowModifyLevel modLevel, List *taskList, ErrorIfTransactionAccessedPlacementsLocally(); } + locallyProcessedRows += ExecuteLocalTaskList(localTaskList, tupleStore); + if (MultiShardConnectionType == SEQUENTIAL_CONNECTION) { targetPoolSize = 1; diff --git a/src/backend/distributed/executor/local_executor.c b/src/backend/distributed/executor/local_executor.c index e2a91079b..df3818883 100644 --- a/src/backend/distributed/executor/local_executor.c +++ b/src/backend/distributed/executor/local_executor.c @@ -136,6 +136,10 @@ static void LocallyExecuteUdfTaskQuery(Query *localUdfCommandQuery); uint64 ExecuteLocalTaskList(List *taskList, Tuplestorestate *tupleStoreState) { + if (list_length(taskList) == 0) + { + return 0; + } DistributedPlan *distributedPlan = NULL; ParamListInfo paramListInfo = NULL; return ExecuteLocalTaskListExtended(taskList, paramListInfo, distributedPlan,