Skip to content

perf: optimize string contains function - #5322

Open
kazantsev-maksim wants to merge 75 commits into
apache:mainfrom
kazantsev-maksim:perf_contains
Open

perf: optimize string contains function#5322
kazantsev-maksim wants to merge 75 commits into
apache:mainfrom
kazantsev-maksim:perf_contains

Conversation

@kazantsev-maksim

@kazantsev-maksim kazantsev-maksim commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • N/A

Rationale for this change

Optimize existing expression.

What changes are included in this PR?

Performance Optimization for Scalar Haystack (Scalar vs Array):

  • Replaced the heavy heap allocation haystack_scalar.to_array_of_size(needle_array.len()) with Arrow's native StringArray::new_scalar(...).
  • Avoids materializing a full $O(N)$ array in memory, shifting to an efficient $O(1)$ broadcasting mechanism (mirroring the optimization already used for scalar needles).

How are these changes tested?

Existing tests.

Benchmark (criterion):

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant