-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
eval: add LIKE patterns without wildcards to optimizedLikeFunc #91895
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find! Might be worth having a sanity test for a couple simple patterns to ensure they get properly optimized. Also, is LIKE
without wildcards the same as =
?
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that adding some tests to assert that optimizedLikeFunc
returns non-nil for the expected patterns would be great.
Without the wildcards and without the escape characters LIKE
is the same to the direct comparison - if we have escape characters, then it's not.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @michae2)
pkg/sql/sem/eval/match.go
line 255 at r1 (raw file):
}, nil default:
nit: maybe add a comment that this default
case is handling both singleAnyStart || singleAnyEnd
as well as the case when there are no wildcard characters in the pattern at all, and in the latter we just get a direct string comparison (modulo case insensitivity).
`eval.optimizedLikeFunc` has special cases for LIKE patterns that start and end with wildcards `%` or `_` which can be evaluated without regular expressions. Add support for patterns with no wildcards at all. Fixes: cockroachdb#91887 Assists: cockroachdb#89749 Epic: None Release note (performance improvement): Performance of the `LIKE` and `ILIKE` operators using patterns without any wildcards has been improved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call on the tests, they made me realize I was missing the length 1 case!
Reviewable status: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @yuzefovich)
pkg/sql/sem/eval/match.go
line 255 at r1 (raw file):
Previously, yuzefovich (Yahor Yuzefovich) wrote…
nit: maybe add a comment that this
default
case is handling bothsingleAnyStart || singleAnyEnd
as well as the case when there are no wildcard characters in the pattern at all, and in the latter we just get a direct string comparison (modulo case insensitivity).
Done.
bors r=DrewKimball,yuzefovich |
Build succeeded: |
eval.optimizedLikeFunc
has special cases for LIKE patterns that start and end with wildcards%
or_
which can be evaluated without regular expressions. Add support for patterns with no wildcards at all.Fixes: #91887
Assists: #89749
Epic: None
Release note (performance improvement): Performance of the
LIKE
andILIKE
operators using patterns without any wildcards has been improved.