Skip to content

Force migration key for composite chunk boundaries - #1761

Merged
jakubpliszka merged 1 commit into
masterfrom
jakubpliszka/force-composite-migration-key
Aug 28, 2026
Merged

Force migration key for composite chunk boundaries#1761
jakubpliszka merged 1 commit into
masterfrom
jakubpliszka/force-composite-migration-key

Conversation

@jakubpliszka

Copy link
Copy Markdown
Contributor

Description

This PR passes the selected migration key into the two column range end query builders and uses it with FORCE INDEX for offset and temporary table boundary queries.

Why

The composite key pagination optimisation introduced in #1686 split range-end discovery into multiple UNION ALL branches. 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.

In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

Copilot AI balanced review requested due to automatic review settings August 28, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 INDEX to 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.

@jakubpliszka
jakubpliszka merged commit f7a42f6 into master Aug 28, 2026
15 checks passed
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.

3 participants