[MDEV-21480] Unique key using ref access though eq_ref access can be used Created: 2020-01-15 Updated: 2020-05-05 Resolved: 2020-05-01 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.1, 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.3.23, 10.4.13, 10.5.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Varun Gupta (Inactive) | Assignee: | Varun Gupta (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Here is the dataset
So the key uses to access t1 is key b, which is a UNIQUE key and due to the condition all the columns in the key
If I have a primary key on (b,c), then eq_ref access is picked. So it would be good if we could use eq_ref access for the first case too! |
| Comments |
| Comment by Varun Gupta (Inactive) [ 2020-04-21 ] | ||||||||||||||||||||||||||||||||||
|
The optimizer trace for the plan t2 and t1 looks like
As we can see during the planner phase we pick eq_ref access but during the function create_ref_for_key we pick the access to be REF access | ||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2020-04-21 ] | ||||||||||||||||||||||||||||||||||
|
Patch | ||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2020-04-30 ] | ||||||||||||||||||||||||||||||||||
|
Ok to push. |