planner: enable fix control 52869 by default to let planner consider IndexMerge when an alternative index exists#63701
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #63701 +/- ##
================================================
- Coverage 77.7266% 76.9958% -0.7308%
================================================
Files 1990 1972 -18
Lines 551959 553217 +1258
================================================
- Hits 429019 425954 -3065
- Misses 122020 127236 +5216
+ Partials 920 27 -893
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
📝 WalkthroughWalkthroughThis PR adjusts the default behavior of the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pkg/planner/core/indexmerge_path.go (1)
529-533: Document the intentional default asymmetry forFix52869.This default is now
truehere, whileShouldPreferIndexMergeinpkg/planner/core/rule/rule_prune_indexes.gostill defaults tofalse. Please add a brief inline comment explaining why both defaults differ intentionally, to avoid accidental “cleanup” regressions later.As per coding guidelines, comments SHOULD explain non-obvious intent, constraints, invariants, concurrency guarantees, SQL/compatibility contracts, or important performance trade-offs.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/planner/core/indexmerge_path.go` around lines 529 - 533, Add a brief inline comment next to the skipRangeScanCheck assignment (the call to fixcontrol.GetBoolWithDefault with fixcontrol.Fix52869) that documents the intentional default asymmetry with ShouldPreferIndexMerge (in rule_prune_indexes.go) — state that skipRangeScanCheck defaults to true here for compatibility/perf/regression reasons while ShouldPreferIndexMerge remains false, and mention the rationale (e.g., backward compatibility or a staged rollout) so future maintainers do not "clean up" the differing defaults; place the comment immediately above or beside the skipRangeScanCheck line and reference Fix52869 and ShouldPreferIndexMerge by name.tests/integrationtest/r/planner/core/indexmerge_path.result (1)
1007-1032: Add an explicit52869:offregression case alongside these new defaults.These updated expectations validate the new default and match the explicit
52869:onsection, but there’s no paired assertion for52869:offon the same query shapes. Adding that would lock down fix-control toggle semantics and prevent silent behavior drift.Based on learnings: Applies to pkg/planner/** : For planner rule or logical/physical plan changes, perform targeted planner unit tests and update rule testdata when needed.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integrationtest/r/planner/core/indexmerge_path.result` around lines 1007 - 1032, Add a paired regression case that explicitly asserts the old behavior under the `52869:off` toggle for the same query shapes shown (the IndexMerge/IndexRangeScan(Build)/Selection(Probe)/TableRowIDScan plans for the three example SELECTs). Copy the three new default expectations and create matching `52869:off` blocks that show the prior plan layout (i.e., the alternative IndexRangeScan ordering/absence you expect when the feature is off), ensuring the blocks reference the same query strings and plan nodes (IndexMerge, IndexRangeScan(Build), Selection(Probe), TableRowIDScan) so the test locks down both `52869:on` (new defaults) and `52869:off` semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/planner/core/indexmerge_path.go`:
- Around line 529-533: Add a brief inline comment next to the skipRangeScanCheck
assignment (the call to fixcontrol.GetBoolWithDefault with fixcontrol.Fix52869)
that documents the intentional default asymmetry with ShouldPreferIndexMerge (in
rule_prune_indexes.go) — state that skipRangeScanCheck defaults to true here for
compatibility/perf/regression reasons while ShouldPreferIndexMerge remains
false, and mention the rationale (e.g., backward compatibility or a staged
rollout) so future maintainers do not "clean up" the differing defaults; place
the comment immediately above or beside the skipRangeScanCheck line and
reference Fix52869 and ShouldPreferIndexMerge by name.
In `@tests/integrationtest/r/planner/core/indexmerge_path.result`:
- Around line 1007-1032: Add a paired regression case that explicitly asserts
the old behavior under the `52869:off` toggle for the same query shapes shown
(the IndexMerge/IndexRangeScan(Build)/Selection(Probe)/TableRowIDScan plans for
the three example SELECTs). Copy the three new default expectations and create
matching `52869:off` blocks that show the prior plan layout (i.e., the
alternative IndexRangeScan ordering/absence you expect when the feature is off),
ensuring the blocks reference the same query strings and plan nodes (IndexMerge,
IndexRangeScan(Build), Selection(Probe), TableRowIDScan) so the test locks down
both `52869:on` (new defaults) and `52869:off` semantics.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d9cb13f3-8a49-497c-93c8-cbc1a46bac6a
📒 Files selected for processing (3)
pkg/planner/core/indexmerge_path.gotests/integrationtest/r/executor/explain.resulttests/integrationtest/r/planner/core/indexmerge_path.result
|
/retest |
1 similar comment
|
/retest |
IndexMerge when an alternative index exists
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 0xPoe, qw4990 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…`IndexMerge` when an alternative index exists (pingcap#63701) ref pingcap#26764
What problem does this PR solve?
Issue Number: ref #26764
Problem Summary:
Please see the issue and the doc.
We have been advising users to enable this flag for similar scenarios, and received no bad cases or bug reports. As we encounter this situation more and more often, we think it makes sense to enable this flag by default.
What changed and how does it work?
Set the default value to
ONby default, and update the test results.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
Summary by CodeRabbit
Bug Fixes
Tests