[MDEV-9133] range chosen for update while ref used for select on multicolumn index with length Created: 2015-11-16 Updated: 2016-01-22 Resolved: 2016-01-22 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0.21 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Daniel Black | Assignee: | Sergei Petrunia |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
When a select form of the same query is used:
(despite obscuring the username it was 7 characters) as both AcctSessionId and UserName are <= 8 characters could a ref lookup be used in the UPDATE statement exactly like the SELECT? related - |
| Comments |
| Comment by Elena Stepanova [ 2015-11-18 ] | |||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-01-22 ] | |||||||||||||||||||||||||||||
|
Note that both plans use key_len: 52. The scan the same range on the same key. Short answer: The difference between range and ref is due to MySQL/MariaDB code internals and is not really meaningful. Long version: Code that handles single-table UPDATE doesn't ever need to compute equijoins. Because of that, it never constructs ref access. It may find it useful to scan key range(s) to find rows, so it can (and does) construct range access. If you change UPDATE to be a multi-table UPDATE, like:
then ref access method will be picked/used, like in SELECT. | |||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-01-22 ] | |||||||||||||||||||||||||||||
|
Closing as Not a Bug. Feel free to re-open if there is anything unresolved. |