perf: Use batched row conversion for array_has_any, array_has_all#20588
Open
neilconway wants to merge 1 commit intoapache:mainfrom
Open
perf: Use batched row conversion for array_has_any, array_has_all#20588neilconway wants to merge 1 commit intoapache:mainfrom
array_has_any, array_has_all#20588neilconway wants to merge 1 commit intoapache:mainfrom
Conversation
Contributor
Author
|
Benchmarks: It's a significant win for short arrays, and a small win for large arrays. For large arrays, the N*M comparison cost probably dominates. We should probably be able to do something smarter by hashing, I'll look at that shortly but in a separate PR. |
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,array_has_all#20587 .Rationale for this change
array_has_anyandarray_has_allcalledRowConverter::convert_columnstwice for every input row.convert_columnshas a lot of per-call overhead: allocating a newRowsbuffer, doing various schema checking, and so on.It is considerably more efficient to use
RowConvertertwice up front and convert all of the haystack and needle inputs in bulk. We can then implement thehas_any/has_allpredicate comparison by indexing into the converted rows.array_has_any/array_has_allhad a special-case for strings, but it had an analogous problem: it iterated over rows, materialized each row's inner list, and then calledstring_array_to_vectwice per row. That does a lot of per-row work; it is significantly faster to callstring_array_to_vecon all input rows at once, and then index into the results to implement the per-row comparisons.What changes are included in this PR?
Are these changes tested?
Yes.
Are there any user-facing changes?
No.