Ensure parallelModeNeeded flag is sent down to the remote node.
authorPavan Deolasee <pavan.deolasee@gmail.com>
Thu, 23 Aug 2018 05:24:37 +0000 (10:54 +0530)
committerPavan Deolasee <pavan.deolasee@gmail.com>
Thu, 23 Aug 2018 05:24:37 +0000 (10:54 +0530)
This still does not solve the problem that the datanodes don't make use of
parallel queries during distributed execution (they work OK if queries are
FQSed). That's because PostgreSQL does not support parallel queries when a
portal is used to fetch only a part of the result set. We need separate patches
to either fix or work-around that.

src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/pgxc/pool/execRemote.c
src/backend/utils/cache/plancache.c
src/include/pgxc/execRemote.h

index f61905d84a4da5a70f86898df01e4a3b0014af27..40ee9eea275dc916496ecc4d098da0c736271b41 100644 (file)
@@ -1571,6 +1571,7 @@ _outRemoteStmt(StringInfo str, const RemoteStmt *node)
 
        WRITE_ENUM_FIELD(commandType, CmdType);
        WRITE_BOOL_FIELD(hasReturning);
+       WRITE_BOOL_FIELD(parallelModeNeeded);
        WRITE_NODE_FIELD(planTree);
        WRITE_NODE_FIELD(rtable);
        WRITE_NODE_FIELD(resultRelations);
index ff752fc1c091176fabb4bb16c97e017a7e05cd0c..5eaf6b36c4951b695dab7cc7f615103135728c7a 100644 (file)
@@ -3649,6 +3649,7 @@ _readRemoteStmt(void)
 
        READ_ENUM_FIELD(commandType, CmdType);
        READ_BOOL_FIELD(hasReturning);
+       READ_BOOL_FIELD(parallelModeNeeded);
        READ_NODE_FIELD(planTree);
        READ_NODE_FIELD(rtable);
        READ_NODE_FIELD(resultRelations);
index c8bc3276fab39351efc2ad42b47dedba5d0b1132..b05943a30481cc594d2f0ef14cb07275102d9fb3 100644 (file)
@@ -5479,6 +5479,7 @@ ExecInitRemoteSubplan(RemoteSubplan *node, EState *estate, int eflags)
                         */
                        RemoteSubplanMakeUnique((Node *) outerPlan(node), PGXCNodeId);
                }
+               rstmt.parallelModeNeeded = estate->es_plannedstmt->parallelModeNeeded;
                rstmt.planTree = outerPlan(node);
                /*
                 * If datanode launch further execution of a command it should tell
index 501cd54b9b52fd2bb051b26c807e47a5a5a0432f..9b9bd47f9ca69348d3a661a94b73bc309526cfc1 100644 (file)
@@ -2062,6 +2062,7 @@ SetRemoteSubplan(CachedPlanSource *plansource, const char *plan_string)
        stmt->distributionKey = rstmt->distributionKey;
        stmt->distributionNodes = rstmt->distributionNodes;
        stmt->distributionRestrict = rstmt->distributionRestrict;
+       stmt->parallelModeNeeded = rstmt->parallelModeNeeded;
 
        /*
         * Set up SharedQueue if intermediate results need to be distributed
index b7c0f5b7a160990982f8751809d78268a7b0d93d..bf73d4c3e7503a7c875b6fca374128ef789c0de7 100644 (file)
@@ -198,6 +198,8 @@ typedef struct RemoteStmt
 
        bool            hasReturning;   /* is it insert|update|delete RETURNING? */
 
+       bool            parallelModeNeeded;
+
        struct Plan *planTree;                          /* tree of Plan nodes */
 
        List       *rtable;                                     /* list of RangeTblEntry nodes */