-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop copying LogicalPlan and Exprs in PushDownLimit
#10508
Conversation
4d5e7cd
to
0a2aeb4
Compare
fetch: scan.fetch.map(|x| min(x, limit)).or(Some(limit)), | ||
projected_schema: scan.projected_schema.clone(), | ||
}); | ||
plan.with_new_exprs(plan.expressions(), vec![new_input]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plan_with_new_exprs copies expressions in addition to all the other clones above, so this removes non trivial number of clones
plan.with_new_exprs(plan.expressions(), vec![union]) | ||
.map(Some) | ||
.into_iter() | ||
.map(|input| make_arc_limit(0, fetch + skip, input)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also moved some of the boiler plate for creating Limit
into their own functions
0a2aeb4
to
dcee6fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks @alamb
/// Limit: skip=skip, fetch=fetch | ||
/// input | ||
/// ``` | ||
fn make_limit(skip: usize, fetch: usize, input: LogicalPlan) -> LogicalPlan { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you use input: Arc<LogicalPlan>
here so you can reuse make_limit
in make_arc_limit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, done in 3259380
Thank you so much for the reviews @comphead -- really appreciated |
* Stop copying LogicalPlan and Exprs in `PushDownLimit` * Refine make_limit
Draft as it builds on #10501Which issue does this PR close?
Closes #10292
Rationale for this change
Make optimizer faster by not copying as much
What changes are included in this PR?
PushDownLimit
to avoid deep cloning LogicalPlans / ExprsAre these changes tested?
Are there any user-facing changes?
No functional changes and very minor (if any) performance improvements
Performance runs Details