mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Avoid projecting tuples unnecessarily in Gather and Gather Merge.
It's most often the case that the target list for the Gather (Merge)
node matches the target list supplied by the underlying plan node;
when this is so, we can avoid the overhead of projecting.
This depends on commit f455e1125e
for
proper functioning.
Idea by Andres Freund. Patch by me. Review by Amit Kapila.
Discussion: http://postgr.es/m/CA+TgmoZ0ZL=cesZFq8c9NnfK6bqy-wwUd3_74iYGodYrSoQ7Fw@mail.gmail.com
This commit is contained in:
@ -103,12 +103,6 @@ ExecInitGather(Gather *node, EState *estate, int eflags)
|
||||
outerNode = outerPlan(node);
|
||||
outerPlanState(gatherstate) = ExecInitNode(outerNode, estate, eflags);
|
||||
|
||||
/*
|
||||
* Initialize result tuple type and projection info.
|
||||
*/
|
||||
ExecAssignResultTypeFromTL(&gatherstate->ps);
|
||||
ExecAssignProjectionInfo(&gatherstate->ps, NULL);
|
||||
|
||||
/*
|
||||
* Initialize funnel slot to same tuple descriptor as outer plan.
|
||||
*/
|
||||
@ -117,6 +111,12 @@ ExecInitGather(Gather *node, EState *estate, int eflags)
|
||||
tupDesc = ExecTypeFromTL(outerNode->targetlist, hasoid);
|
||||
ExecSetSlotDescriptor(gatherstate->funnel_slot, tupDesc);
|
||||
|
||||
/*
|
||||
* Initialize result tuple type and projection info.
|
||||
*/
|
||||
ExecAssignResultTypeFromTL(&gatherstate->ps);
|
||||
ExecConditionalAssignProjectionInfo(&gatherstate->ps, tupDesc, OUTER_VAR);
|
||||
|
||||
return gatherstate;
|
||||
}
|
||||
|
||||
@ -221,6 +221,10 @@ ExecGather(PlanState *pstate)
|
||||
if (TupIsNull(slot))
|
||||
return NULL;
|
||||
|
||||
/* If no projection is required, we're done. */
|
||||
if (node->ps.ps_ProjInfo == NULL)
|
||||
return slot;
|
||||
|
||||
/*
|
||||
* Form the result tuple using ExecProject(), and return it.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user