mirror of https://github.com/citusdata/citus.git
Perform distributed planning in the calling memory context
Previously we used, for historical reasons, MessageContext. That is problematic if a single message from the client causes a lot of statements to be planned. E.g. for the copy_to_distributed_table script one insert statement is planned for each row inserted via COPY, and only freed when COPY has finished.pull/332/head
parent
136306a1fe
commit
0a6839e544
|
@ -52,19 +52,10 @@ multi_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
|
|||
|
||||
if (NeedsDistributedPlanning(parse))
|
||||
{
|
||||
MemoryContext oldcontext = NULL;
|
||||
MultiPlan *physicalPlan = NULL;
|
||||
|
||||
/* Switch to top level message context */
|
||||
oldcontext = MemoryContextSwitchTo(MessageContext);
|
||||
|
||||
physicalPlan = CreatePhysicalPlan(parse);
|
||||
MultiPlan *physicalPlan = CreatePhysicalPlan(parse);
|
||||
|
||||
/* store required data into the planned statement */
|
||||
result = MultiQueryContainerNode(result, physicalPlan);
|
||||
|
||||
/* Now switch back to original context */
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue