perf: Optimize array_has_any() with scalar arg#20385
Open
neilconway wants to merge 5 commits intoapache:mainfrom
Open
perf: Optimize array_has_any() with scalar arg#20385neilconway wants to merge 5 commits intoapache:mainfrom
array_has_any() with scalar arg#20385neilconway wants to merge 5 commits intoapache:mainfrom
Conversation
Contributor
Author
|
Benchmark results: |
cc2d735 to
ef696bd
Compare
The previous implementation tested the cost of building an array_has() `Expr` (!), not actually evaluating the array_has() operation itself. Refactor things along the way.
83484af to
b3bbf3a
Compare
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?
array_has_any()for scalar arg #20384.array_has#18181 for related context.Rationale for this change
When
array_has_anyis passed a scalar for either of its argument, we can use a much faster algorithm: rather than doing O(N*M) comparisons for each row of the columnar arg, we can build a hash table on the scalar array and probe it instead.What changes are included in this PR?
Note that we fallback to a linear scan when the scalar arg is smaller than a threshold (<= 8 elements), because benchmarks suggested probing a HashSet is not profitable for very small arrays.
Are these changes tested?
Yes. Tests pass and benchmarked.
Are there any user-facing changes?
No.