Skip to content

Expand tuple comparisons into nested OR/AND form before normalization#68

Open
axiak wants to merge 1 commit into
release-22-hubspotfrom
ma-tuple-range-query-compiler
Open

Expand tuple comparisons into nested OR/AND form before normalization#68
axiak wants to merge 1 commit into
release-22-hubspotfrom
ma-tuple-range-query-compiler

Conversation

@axiak
Copy link
Copy Markdown

@axiak axiak commented May 7, 2026

Description

Rewrites expressions like (a,b,c) > (x,y,z) into the equivalent nested form: (a>x OR (a=x AND (b>y OR (b=y AND c>z)))). This enables MySQL to use individual column indexes instead of requiring a composite index matching the tuple order.

Applies to >, >=, <, <= operators when the LHS consists entirely of column references.

Gated behind --expand_tuple_comparisons flag (default false).

Related Issue(s)

This is a workaround over this longstanding MySQL bug: https://bugs.mysql.com/bug.php?id=111952

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Rewrites expressions like (a,b,c) > (x,y,z) into the equivalent
nested form: (a>x OR (a=x AND (b>y OR (b=y AND c>z)))). This
enables MySQL to use individual column indexes instead of requiring
a composite index matching the tuple order.

Applies to >, >=, <, <= operators when the LHS consists entirely
of column references.

Gated behind --expand_tuple_comparisons flag (default false).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants