Stop copying LogicalPlan and Exprs in PushDownLimit#10508
Merged
alamb merged 3 commits intoapache:mainfrom May 17, 2024
Merged
Conversation
4d5e7cd to
0a2aeb4
Compare
alamb
commented
May 14, 2024
| 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]) |
Contributor
Author
There was a problem hiding this comment.
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)) |
Contributor
Author
There was a problem hiding this comment.
I also moved some of the boiler plate for creating Limit into their own functions
0a2aeb4 to
dcee6fe
Compare
comphead
approved these changes
May 16, 2024
| /// Limit: skip=skip, fetch=fetch | ||
| /// input | ||
| /// ``` | ||
| fn make_limit(skip: usize, fetch: usize, input: LogicalPlan) -> LogicalPlan { |
Contributor
There was a problem hiding this comment.
I think if you use input: Arc<LogicalPlan> here so you can reuse make_limit in make_arc_limit
Contributor
Author
|
Thank you so much for the reviews @comphead -- really appreciated |
findepi
pushed a commit
to findepi/datafusion
that referenced
this pull request
Jul 16, 2024
* Stop copying LogicalPlan and Exprs in `PushDownLimit` * Refine make_limit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?
PushDownLimitto 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