Configuration:
1 GTM, 1 Coordinator, 2 Datanodes(datanode1, datanode2)
Query:
insert into contact (id, name, phone) values (1,'tom','12345678');
Problem:
Coordinator composes a Remote Plan which includes the ModifyTable plan. The ModifyTable plan includes another Remote Plan which includes the Result plan. Coordinator sends the whole Remote plan to both datanode1[backend process 1] and datanode2[backend process 2].
When datanode1[backend process 1] recieves the plan, it runs the plan and sends the Result plan to datanode1[backend process 3] and get the row from datanode1[backend process 3]. Similarly ,when datanode2[backend process 2] recieves the plan, it sends the Result plan to datanode1[backend process 4] and get the row from datanode1[backend process 4].
I checked the code and found the Result plan is put into the Remote plan in the following code.
Is it possible to optimize the code to remove the Remote plan?
static Plan
grouping_planner(PlannerInfo root, double tuple_fraction)
{
.....
else
result_plan = (Plan *) make_remotesubplan(root,
result_plan,
root->distribution,
distribution,
NULL);
.....
return result_plan;
}