[MDEV-20459] Selectivity of equality condition in ref access not discounted if range access on same index involved a non-equality condition Created: 2019-08-31 Updated: 2023-12-05 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.1, 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Varun Gupta (Inactive) | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
So filtered here shows 80%. The reason is we set filtered during best_access_path and there we actually picked ref access instead of range and later in plan refinement stage we switched the plan to use range access instead of ref access. The optimizer trace shows that we picked ref access first
ref access on f2 is cheaper than range access on f2. |
| Comments |
| Comment by Varun Gupta (Inactive) [ 2019-09-02 ] | ||||||||||||||||||||||||
|
Lets consider an example: So ref access in this case would be picked for 2 keyparts (a=1 and b=2) Issue 1:There are cases when ref access estimates are too optimistic and we prefer to use ranges estimates instead. The problem with this case is if we use range estimates Issue 2:It would be better if we could get the individual selectiivties of columns that are part of the index. In this case we can easily get the selectivity for columns a,b,c. This would gives us the selectivity for column a and b for the index idx. If ref access is picked then we should discount this selectivity of a and b from the original selectivity and the selectivity | ||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-09-03 ] | ||||||||||||||||||||||||
|
Inside the function table_cond_selectivity we have this code where we try to discount of the selectivity for the range scan if all they const key parts are part both the range and ref access. But also in this code I see that the for loop is not needed, looks like dead code to me.
| ||||||||||||||||||||||||
| Comment by Julien Fritsch [ 2023-12-05 ] | ||||||||||||||||||||||||
|
Automated message: | ||||||||||||||||||||||||
| Comment by JiraAutomate [ 2023-12-05 ] | ||||||||||||||||||||||||
|
Automated message: |