perf: Optimize logical optimizer's OptimizeProjections pass#21726
Open
neilconway wants to merge 4 commits intoapache:mainfrom
Open
perf: Optimize logical optimizer's OptimizeProjections pass#21726neilconway wants to merge 4 commits intoapache:mainfrom
OptimizeProjections pass#21726neilconway wants to merge 4 commits intoapache:mainfrom
Conversation
Contributor
Author
|
run benchmark sql_planner |
|
🤖 Criterion benchmark running (GKE) | trigger CPU Details (lscpu)Comparing neilc/perf-planner-optimize-projections (8788049) to b75df6f (merge-base) diff File an issue against this benchmark runner |
|
🤖 Criterion benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
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.
Which issue does this PR close?
OptimizeProjectionsin the logical query optimizer #21724.Rationale for this change
Some profiling suggested that
OptimizeProjectionswas among the most heavyweight of the logical optimizer passes for TPC-DS. This PR implements two distinct optimizations:In
RequiredIndices::add_expr, the previous implementation created aHashSetand walked the expression tree twice, adding reference columns to theHashSet. Finally, members of theHashSetwere converted to indices. It is faster to just walk the expression tree once ourselves and convert column references to indices. This saves the HashSet allocation and insertions, plus one redundant tree walk.In
optimize_projections, we computed the minimal required set ofGROUP BYcolumns, based on functional dependencies. This was relatively expensive; when there are no functional dependencies (common), this was still quite expensive but will always be a no-op. Add a short-circuit to skip the redundant computation in this scenario.Results on a newly added
optimize_projectionsmicrobenchmark:What changes are included in this PR?
optimize_projectionsAre these changes tested?
Yes.
Are there any user-facing changes?
No.