mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Add a Gather executor node.
A Gather executor node runs any number of copies of a plan in an equal number of workers and merges all of the results into a single tuple stream. It can also run the plan itself, if the workers are unavailable or haven't started up yet. It is intended to work with the Partial Seq Scan node which will be added in future commits. It could also be used to implement parallel query of a different sort by itself, without help from Partial Seq Scan, if the single_copy mode is used. In that mode, a worker executes the plan, and the parallel leader does not, merely collecting the worker's results. So, a Gather node could be inserted into a plan to split the execution of that plan across two processes. Nested Gather nodes aren't currently supported, but we might want to add support for that in the future. There's nothing in the planner to actually generate Gather nodes yet, so it's not quite time to break out the champagne. But we're getting close. Amit Kapila. Some designs suggestions were provided by me, and I also reviewed the patch. Single-copy mode, documentation, and other minor changes also by me.
This commit is contained in:
@ -100,6 +100,7 @@
|
||||
#include "executor/nodeMergejoin.h"
|
||||
#include "executor/nodeModifyTable.h"
|
||||
#include "executor/nodeNestloop.h"
|
||||
#include "executor/nodeGather.h"
|
||||
#include "executor/nodeRecursiveunion.h"
|
||||
#include "executor/nodeResult.h"
|
||||
#include "executor/nodeSamplescan.h"
|
||||
@ -113,6 +114,7 @@
|
||||
#include "executor/nodeValuesscan.h"
|
||||
#include "executor/nodeWindowAgg.h"
|
||||
#include "executor/nodeWorktablescan.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "miscadmin.h"
|
||||
|
||||
|
||||
@ -307,6 +309,11 @@ ExecInitNode(Plan *node, EState *estate, int eflags)
|
||||
estate, eflags);
|
||||
break;
|
||||
|
||||
case T_Gather:
|
||||
result = (PlanState *) ExecInitGather((Gather *) node,
|
||||
estate, eflags);
|
||||
break;
|
||||
|
||||
case T_Hash:
|
||||
result = (PlanState *) ExecInitHash((Hash *) node,
|
||||
estate, eflags);
|
||||
@ -504,6 +511,10 @@ ExecProcNode(PlanState *node)
|
||||
result = ExecUnique((UniqueState *) node);
|
||||
break;
|
||||
|
||||
case T_GatherState:
|
||||
result = ExecGather((GatherState *) node);
|
||||
break;
|
||||
|
||||
case T_HashState:
|
||||
result = ExecHash((HashState *) node);
|
||||
break;
|
||||
@ -658,6 +669,10 @@ ExecEndNode(PlanState *node)
|
||||
ExecEndSampleScan((SampleScanState *) node);
|
||||
break;
|
||||
|
||||
case T_GatherState:
|
||||
ExecEndGather((GatherState *) node);
|
||||
break;
|
||||
|
||||
case T_IndexScanState:
|
||||
ExecEndIndexScan((IndexScanState *) node);
|
||||
break;
|
||||
@ -769,3 +784,34 @@ ExecEndNode(PlanState *node)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ExecShutdownNode
|
||||
*
|
||||
* Give execution nodes a chance to stop asynchronous resource consumption
|
||||
* and release any resources still held. Currently, this is only used for
|
||||
* parallel query, but we might want to extend it to other cases also (e.g.
|
||||
* FDW). We might also want to call it sooner, as soon as it's evident that
|
||||
* no more rows will be needed (e.g. when a Limit is filled) rather than only
|
||||
* at the end of ExecutorRun.
|
||||
*/
|
||||
bool
|
||||
ExecShutdownNode(PlanState *node)
|
||||
{
|
||||
if (node == NULL)
|
||||
return false;
|
||||
|
||||
switch (nodeTag(node))
|
||||
{
|
||||
case T_GatherState:
|
||||
{
|
||||
ExecShutdownGather((GatherState *) node);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return planstate_tree_walker(node, ExecShutdownNode, NULL);
|
||||
}
|
||||
|
Reference in New Issue
Block a user