-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Fix the inappropriate heuristic method to estimate the equal condition selectivity #18461
Comments
Here is PG's method in this case:
|
Why don't we directly use 1/NDV, just like Oracle does? //disable auto analyze explain select count(*) from t1 where type=2; without this adjust: |
/assign @qw4990 |
Development Task
Now in the planner, if the estimated value is out of range, which means we cannot find it in the
CMSketch
, a heuristic method is used, which isselectivity = 1 / NDV * (ModifyRows / TotalRows)
.Compared with Oracle's method
selectivity = 1 / NDV
, our method may result in an inappropriate low selectivity, especially when there are a few rows modified, for example, if one row is modified, it would be1 / NDV * (1 / TotalRows)
.It's better to use
1 / NDV
or1 / NDV * (1 - ModifyRows / TotalRows)
.The text was updated successfully, but these errors were encountered: