Force migration key for composite chunk boundaries - #1761
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: None
What changed in this PR
Ensures two-column chunk-boundary queries consistently use the validated migration index.
Changes:
- Passes the migration key into range-end query builders.
- Adds
FORCE INDEXto offset and temporary-table query variants. - Updates unit tests for primary and secondary indexes.
| File | Description |
|---|---|
go/sql/builder.go |
Adds and applies the migration-key index hint. |
go/sql/builder_test.go |
Verifies generated forced-index queries. |
go/logic/applier.go |
Supplies the selected migration key. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ericyan
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR passes the selected migration key into the two column range end query builders and uses it with
FORCE INDEXfor offset and temporary table boundary queries.Why
The composite key pagination optimisation introduced in #1686 split range-end discovery into multiple
UNION ALLbranches. Each branch was left unhinted, allowing MySQL to independently choose an unrelated secondary index.Depending on table statistics and data distribution, MySQL could select a covering skip scan and sort instead of walking the migration key. Because gh-ost runs this boundary query before every chunk, even a small per-query regression can make a migration effectively stall.
The row copy query already forces gh-ost’s validated migration key. This change makes boundary discovery follow the same index consistently and removes shard- or data-dependent optimiser choices.
script/cibuildreturns with no formatting errors, build errors or unit test errors.