Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: fix the inappropriate out-of-range range estimation rule #20989

Open
qw4990 opened this issue Nov 11, 2020 · 3 comments · May be fixed by #21207
Open

planner: fix the inappropriate out-of-range range estimation rule #20989

qw4990 opened this issue Nov 11, 2020 · 3 comments · May be fixed by #21207
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. priority/release-blocker This issue blocks a release. Please solve it ASAP. type/enhancement The issue or PR belongs to an enhancement.
Milestone

Comments

@qw4990
Copy link
Contributor

qw4990 commented Nov 11, 2020

Development Task

When estimating the number of rows for ranges in GetColumnRowCount, if the range is out-of-range, for example, the range's upper bound is less than the minimum value in statistics, TiDB uses outOfRangeEQSelectivity, but this is inappropriate since outOfRangeEQSelectivity is created for point estimation instead of range estimation.
It's better to create a new function outOfRangeIntervalSelectivity for range estimation.

This function outOfRangeIntervalSelectivity can be implemented as:

func outOfRangeIntervalSelectivity(range, modifyCount) float64 {
    stat_width = stat_maximum - stat-minimum
    range_width = range_upper - range_lower
    range_count = stat_total_count * (range_width / stat_width)
    return min(range_count, modifyCount)
}
@qw4990 qw4990 added the type/enhancement The issue or PR belongs to an enhancement. label Nov 11, 2020
@qw4990 qw4990 self-assigned this Nov 11, 2020
@qw4990 qw4990 added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Nov 11, 2020
@qw4990
Copy link
Contributor Author

qw4990 commented Nov 11, 2020

@tangwz Would you like to take a look at this?

@tangwz
Copy link
Contributor

tangwz commented Nov 12, 2020

/assign

@qw4990
Copy link
Contributor Author

qw4990 commented Nov 12, 2020

@tangwz You can refer to Histogram.calcFraction to know how to calculate width~

@SunRunAway SunRunAway added this to the v4.0.9 milestone Nov 17, 2020
@SunRunAway SunRunAway added priority/P0 The issue has P0 priority. priority/release-blocker This issue blocks a release. Please solve it ASAP. and removed priority/P0 The issue has P0 priority. labels Nov 17, 2020
@SunRunAway SunRunAway modified the milestones: v4.0.9, v4.0.10 Nov 25, 2020
@jebter jebter modified the milestones: v4.0.10, v4.0.11 Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. priority/release-blocker This issue blocks a release. Please solve it ASAP. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants