Skip to content

Commit 0acf529

Browse files
committed
chore(cubestore): Upgrade DF: Reduce the amount of redundant planning and optimization
1 parent 86d25b1 commit 0acf529

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

rust/cubestore/cubestore/src/queryplanner/query_executor.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,13 @@ impl QueryExecutor for QueryExecutorImpl {
313313
)?;
314314
let pre_serialized_plan = Arc::new(pre_serialized_plan);
315315
let ctx = self.router_context(cluster.clone(), pre_serialized_plan.clone())?;
316-
let router_plan = ctx
317-
.clone()
318-
.state()
319-
.create_physical_plan(pre_serialized_plan.logical_plan())
320-
.await?;
316+
// We don't want to use session_state.create_physical_plan(...) because it redundantly
317+
// optimizes the logical plan, which has already been optimized before it was put into a
318+
// SerializedPlan (and that takes too much time).
319+
let session_state = ctx.state();
320+
let execution_plan = session_state.query_planner().create_physical_plan(pre_serialized_plan.logical_plan(), &session_state).await?;
321321
Ok((
322-
ctx.clone()
323-
.state()
324-
.create_physical_plan(pre_serialized_plan.logical_plan())
325-
.await?,
322+
execution_plan,
326323
pre_serialized_plan.logical_plan().clone(),
327324
))
328325
}
@@ -346,12 +343,11 @@ impl QueryExecutor for QueryExecutorImpl {
346343
worker_planning_params,
347344
data_loaded_size,
348345
)?;
349-
let plan_ctx = ctx.clone();
346+
// We don't want to use session_state.create_physical_plan(...); see comment in router_plan.
347+
let session_state = ctx.state();
348+
let execution_plan = session_state.query_planner().create_physical_plan(pre_serialized_plan.logical_plan(), &session_state).await?;
350349
Ok((
351-
plan_ctx
352-
.state()
353-
.create_physical_plan(pre_serialized_plan.logical_plan())
354-
.await?,
350+
execution_plan,
355351
pre_serialized_plan.logical_plan().clone(),
356352
))
357353
}

0 commit comments

Comments
 (0)