[MDEV-24974] Query optimizer not use index with ORDER BY with CASE Created: 2021-02-24 Updated: 2021-03-28 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer, Server, Storage Engine - InnoDB |
| Affects Version/s: | 10.3.27 |
| Fix Version/s: | 10.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | DAIKOZ | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | innodb, performance | ||
| Environment: |
Server version: 10.3.27-MariaDB-0+deb10u1-log Debian 10 |
||
| Description |
|
Performance issue when use CASE with ORDER BY: index is not used. When do:
=> the index on primary key is used When do on same table:
=> all rows are parsed (performance issue on large table). No index of primary key is used even if variable @sortBy is defined before the query. To simplify, I create this example:
id|select_type|table|type |possible_keys|key |key_len|ref|rows|Extra|
id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra | |