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

Ensure that hex query predicates are normalized for planner cache #9118

Merged
merged 4 commits into from
Nov 4, 2021

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Oct 29, 2021

Description

We were not normalizing hex values of either format:

  • 0x01
  • x'73757265'

This had a major performance impact in workloads where hex query predicates are used in common queries as we could not leverage the query planner cache. This work normalizes them.

Note: the only explicitly non-normalized values are now bit types of the format b'1':

mysql> select b'011101110111010101110100' /* wut */;
+----------------------------------------------------------+
| b'011101110111010101110100'                              |
+----------------------------------------------------------+
| 0x777574                                                 |
+----------------------------------------------------------+
1 row in set (0.00 sec)

Should we try and handle those here as well???

Related Issue(s)

#9101

Checklist

  • Should this PR be backported? Yes, at least to 12.0 IMO
  • Tests were added
  • Documentation is not required

@mattlord
Copy link
Contributor Author

mattlord commented Nov 2, 2021

@mattlord mattlord force-pushed the NormalizeHexValuesInQueries branch 7 times, most recently from 624dc38 to a9fed7e Compare November 3, 2021 14:14
@mattlord mattlord changed the title Ensure that all query parameter types are normalized for planner cache Ensure that hex parameter types are normalized for planner cache Nov 3, 2021
@mattlord mattlord changed the title Ensure that hex parameter types are normalized for planner cache Ensure that hex query predicates are normalized for planner cache Nov 3, 2021
@mattlord mattlord force-pushed the NormalizeHexValuesInQueries branch 3 times, most recently from bb56452 to 1912acc Compare November 3, 2021 15:32
@mattlord mattlord marked this pull request as ready for review November 3, 2021 15:43
go/vt/sqlparser/ast_funcs.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@systay systay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice stuff

@mattlord mattlord force-pushed the NormalizeHexValuesInQueries branch 2 times, most recently from e9f4e94 to c130482 Compare November 3, 2021 16:27
@mattlord mattlord requested a review from pH14 as a code owner November 3, 2021 19:43
@mattlord mattlord force-pushed the NormalizeHexValuesInQueries branch 2 times, most recently from 6375eed to aa83316 Compare November 3, 2021 19:51
@mattlord mattlord removed the request for review from pH14 November 3, 2021 19:58
Copy link
Member

@frouioui frouioui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very nice!

java/client/pom.xml Outdated Show resolved Hide resolved
Signed-off-by: Matt Lord <mattalord@gmail.com>
This is only dealing with HEXNUM valus, e.g. 0x01
Leaving Hex values, e.g. x'01', for later...

Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord force-pushed the NormalizeHexValuesInQueries branch from aa83316 to e622ebd Compare November 3, 2021 22:46
@systay systay merged commit f085f12 into vitessio:main Nov 4, 2021
@systay systay deleted the NormalizeHexValuesInQueries branch November 4, 2021 14:22
mattlord pushed a commit to planetscale/vitess that referenced this pull request Nov 5, 2021
…nQueries

Ensure that hex query predicates are normalized for planner cache

Signed-off-by: Matt Lord <mattalord@gmail.com>
mattlord pushed a commit to planetscale/vitess that referenced this pull request Nov 9, 2021
…nQueries

Ensure that hex query predicates are normalized for planner cache

Signed-off-by: Matt Lord <mattalord@gmail.com>
DeathBorn pushed a commit to vinted/vitess that referenced this pull request Jan 27, 2023
…lizeHexValuesInQueries vitessio@322ac09 using vitessio#9163 as a guide

Merge pull request vitessio#9118 from planetscale/NormalizeHexValuesInQueries

Ensure that hex query predicates are normalized for planner cache

Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Vilius Okockis <vilius.okockis@vinted.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants