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

opt: normalize LIKE 'forest%' to x >= 'forest' AND x < 'foresu' #52153

Closed
RaduBerinde opened this issue Jul 30, 2020 · 4 comments
Closed

opt: normalize LIKE 'forest%' to x >= 'forest' AND x < 'foresu' #52153

RaduBerinde opened this issue Jul 30, 2020 · 4 comments
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) good first issue

Comments

@RaduBerinde
Copy link
Member

Index constraint generation currently supports constraints from LIKE expressions, but the opt statistics code does not. A simple improvement would be to handle the case where the expression is exactly equivalent to a range of values.

Note that such a rule would need to handle escaping correctly (which the index constraints code currently does not, see #44123).

@RaduBerinde RaduBerinde added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) good first issue labels Jul 30, 2020
@RaduBerinde RaduBerinde changed the title opt: normalize LIKE 'forest%' to BETWEEN 'forest' AND 'foresu' opt: normalize LIKE 'forest%' to x >= 'forest' AND x < 'foresu' Jul 30, 2020
@xuhui-lu
Copy link
Contributor

hey @RaduBerinde , is this ticket assigned? If not, can I take it? I am glad to do some work on it.

@RaduBerinde
Copy link
Member Author

Sure, thanks!

@ipugh
Copy link

ipugh commented Aug 26, 2020

Hey @xuhui-lu are you still working on this? If not I'd like to give it a go.

ipugh pushed a commit to ipugh/cockroach that referenced this issue Aug 27, 2020
It is easier to calculate stats for a `Range` expression than for
`Like` expressions. This PR adds a rule that converts a `Like` operator
with tight constraints to a `Range` operator.

Fixes cockroachdb#52153

Release note: None

Release justification: This change is small and is unlikely to break
anything.
@RaduBerinde
Copy link
Member Author

Turns out there is not much benefit to this, we can create constraints from LIKE just the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants