Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache LIKE regexes #320

Merged
merged 7 commits into from
Sep 12, 2024
Merged

Cache LIKE regexes #320

merged 7 commits into from
Sep 12, 2024

Conversation

barbarj
Copy link
Contributor

@barbarj barbarj commented Sep 10, 2024

Fixes: #168

This PR adds a regex cache to ProgramState so that we ca re-use already constructed regexes while processing LIKE expressions. I didn't find anywhere else that seemed like a good fit to put an execution-time only cache like this, so let me know if there's a better spot.

To best match sqlite, I added the constant mask into the Function instruction (this indicates whether the first argument to the function was determined to be constant at compile time), and decide whether to use the cache based on its value. I've left the value for constant_mask as 0 on every other kind of Function instruction. That seemed to be the safest choice, as that appears to be what has been implicitly done up to this point. Happy to change that if you'd advise otherwise.

@penberg penberg closed this in 9c1bdf9 Sep 12, 2024
@penberg penberg merged commit 9c1bdf9 into tursodatabase:main Sep 12, 2024
30 checks passed
@barbarj barbarj deleted the cache-like-regexes branch September 12, 2024 16:20
penberg added a commit that referenced this pull request Sep 22, 2024
This PR adds a regex cache to `ProgramState` so that we ca re-use
already constructed regexes while processing LIKE expressions. I didn't
find anywhere else that seemed like a good fit to put an execution-time
only cache like this, so let me know if there's a better spot.
To best match sqlite, I added the constant mask into the `Function`
instruction (this indicates whether the first argument to the function
was determined to be constant at compile time), and decide whether to
use the cache based on its value. I've left the value for
`constant_mask` as 0 on every other kind of `Function` instruction. That
seemed to be the safest choice, as that appears to be what has been
implicitly done up to this point. Happy to change that if you'd advise
otherwise.

Fixes #168
Closes #320
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.

Reuse Regex in LIKE implementation
3 participants