Skip to content

Conversation

@terry1purcell
Copy link
Contributor

@terry1purcell terry1purcell commented Jan 27, 2026

What problem does this PR solve?

Issue Number: ref #65294

Problem Summary:

What changed and how does it work?

Variable tidb_opt_risk_range_skew_ratio can be used to adjust the estimation in 2 scenarios:

  • out of range estimation
  • within a histogram bucket estimate
    Customers attempting to use this variable to adjust only the out-of-range estimate have incurred unexpected plan changes due to the impact on "within bucket estimation".
    Given that out-of-range is the more critical customer issue - this PR reduces the impact that tidb_opt_risk_range_skew_ratio has on within bucket estimation, and adds a TODO to note that further work is required if customers also experience estimation issues within histogram buckets.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. component/statistics sig/planner SIG: Planner labels Jan 27, 2026
@tiprow
Copy link

tiprow bot commented Jan 27, 2026

Hi @terry1purcell. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@terry1purcell
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Jan 27, 2026
@terry1purcell terry1purcell requested a review from Copilot January 27, 2026 18:22
@terry1purcell terry1purcell changed the title planner: reduce in bucket usage of range risk planner: reduce within bucket usage of range risk Jan 27, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts histogram range row-count estimation to reduce the effect of tidb_opt_risk_range_skew_ratio on in-bucket estimates, while still tracking a “worst-case” max estimate for planner risk evaluation.

Changes:

  • Switches BetweenRowCount’s internal rangeEst computation to use RowEstimate directly throughout.
  • Modifies the in-bucket skew handling to cap how much RiskRangeSkewRatio can inflate the default estimate, and updates MaxEst for risk-based comparisons.
  • Adds a TODO note documenting the intent and future follow-up area.

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.3149%. Comparing base (e8a60bd) to head (e457c1e).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #65856        +/-   ##
================================================
+ Coverage   77.7750%   78.3149%   +0.5398%     
================================================
  Files          2001       1923        -78     
  Lines        545527     533123     -12404     
================================================
- Hits         424284     417515      -6769     
+ Misses       119581     115165      -4416     
+ Partials       1662        443      -1219     
Flag Coverage Δ
integration 44.2039% <72.2222%> (-3.9609%) ⬇️
unit 76.7126% <100.0000%> (+0.3013%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 56.7974% <ø> (ø)
parser ∅ <ø> (∅)
br 48.8517% <ø> (-12.1388%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

terry1purcell and others added 2 commits January 27, 2026 11:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Corrected a typo in a comment regarding the usage of RiskRangeSkewRatio.
@terry1purcell
Copy link
Contributor Author

/retest-required

Copy link
Contributor

@fixdb fixdb left a comment

Choose a reason for hiding this comment

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

+1

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jan 28, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fixdb
Once this PR has been reviewed and has the lgtm label, please assign 0xpoe for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jan 28, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jan 28, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-01-28 09:38:18.04733577 +0000 UTC m=+1177925.661292616: ☑️ agreed by fixdb.

@terry1purcell
Copy link
Contributor Author

/retest-required

@terry1purcell terry1purcell requested a review from 0xPoe January 28, 2026 20:33
@terry1purcell
Copy link
Contributor Author

/retest-required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/statistics needs-1-more-lgtm Indicates a PR needs 1 more LGTM. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants