Details
-
Task
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
Description
As of c10e10c6, opt_sum.cc is still stubbed for DESC indexes
if (part->key_part_flag & HA_REVERSE_SORT)
|
break; // TODO MDEV-13756
|
Given that we are about to close MDEV-13756, it looks strange: either it was forgotten and needs to be enabled, or maybe it requires a better reference.
Given the above, the optimization expectedly doesn't work.
--source include/have_sequence.inc
|
|
create or replace table t1 (id int, key(id)); |
insert into t1 select seq from seq_1_to_100 order by rand(1); |
explain extended select max(id) from t1 where id > 50; |
|
create or replace table t1 (id int, key(id desc)); |
insert into t1 select seq from seq_1_to_100 order by rand(1); |
explain extended select max(id) from t1 where id > 50; |
|
# Cleanup
|
drop table t1; |
With the ASC index, it is
preview-10.8-MDEV-13756-desc-indexes c10e10c6 |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+------------------------------+ |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+------------------------------+ |
| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Select tables optimized away | |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+------------------------------+ |
With the DESC index, it is
+------+-------------+-------+-------+---------------+------+---------+------+------+----------+--------------------------+ |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | |
+------+-------------+-------+-------+---------------+------+---------+------+------+----------+--------------------------+ |
| 1 | SIMPLE | t1 | range | id | id | 5 | NULL | 50 | 100.00 | Using where; Using index | |
+------+-------------+-------+-------+---------------+------+---------+------+------+----------+--------------------------+ |
Attachments
Issue Links
- is caused by
-
MDEV-13756 Implement descending index: KEY (a DESC, b ASC)
-
- Closed
-
- relates to
-
MDEV-32732 Support DESC indexes in loose scan optimization
-
- In Testing
-
Activity
Field | Original Value | New Value |
---|---|---|
Link |
This issue is caused by |
Description |
As of c10e10c6, opt_sum.cc is still stubbed for DESC indexes
{noformat} if (part->key_part_flag & HA_REVERSE_SORT) break; // TODO {noformat} Given that we are about to close Given the above, the optimization expectedly doesn't work. {code:sql} --source include/have_innodb.inc --source include/have_sequence.inc create or replace table t1 (id int, key(id)); insert into t1 select seq from seq_1_to_100 order by rand(1); explain extended select max(id) from t1 where id > 50; create or replace table t1 (id int, key(id desc)); insert into t1 select seq from seq_1_to_100 order by rand(1); explain extended select max(id) from t1 where id > 50; # Cleanup drop table t1; {code} With the ASC index, it is {code:sql|title=preview-10.8- +------+-------------+-------+------+---------------+------+---------+------+------+----------+------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +------+-------------+-------+------+---------------+------+---------+------+------+----------+------------------------------+ | 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Select tables optimized away | +------+-------------+-------+------+---------------+------+---------+------+------+----------+------------------------------+ {code} With the DESC index, it is {code:sql} +------+-------------+-------+-------+---------------+------+---------+------+------+----------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +------+-------------+-------+-------+---------------+------+---------+------+------+----------+--------------------------+ | 1 | SIMPLE | t1 | range | id | id | 5 | NULL | 50 | 100.00 | Using where; Using index | +------+-------------+-------+-------+---------------+------+---------+------+------+----------+--------------------------+ {code} |
As of c10e10c6, opt_sum.cc is still stubbed for DESC indexes
{noformat} if (part->key_part_flag & HA_REVERSE_SORT) break; // TODO {noformat} Given that we are about to close Given the above, the optimization expectedly doesn't work. {code:sql} --source include/have_sequence.inc create or replace table t1 (id int, key(id)); insert into t1 select seq from seq_1_to_100 order by rand(1); explain extended select max(id) from t1 where id > 50; create or replace table t1 (id int, key(id desc)); insert into t1 select seq from seq_1_to_100 order by rand(1); explain extended select max(id) from t1 where id > 50; # Cleanup drop table t1; {code} With the ASC index, it is {code:sql|title=preview-10.8- +------+-------------+-------+------+---------------+------+---------+------+------+----------+------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +------+-------------+-------+------+---------------+------+---------+------+------+----------+------------------------------+ | 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Select tables optimized away | +------+-------------+-------+------+---------------+------+---------+------+------+----------+------------------------------+ {code} With the DESC index, it is {code:sql} +------+-------------+-------+-------+---------------+------+---------+------+------+----------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +------+-------------+-------+-------+---------------+------+---------+------+------+----------+--------------------------+ | 1 | SIMPLE | t1 | range | id | id | 5 | NULL | 50 | 100.00 | Using where; Using index | +------+-------------+-------+-------+---------------+------+---------+------+------+----------+--------------------------+ {code} |
Assignee | Sergei Golubchik [ serg ] | Sergei Petrunia [ psergey ] |
Comment | [ A comment with security level 'Developers' was removed. ] |
Fix Version/s | 10.11 [ 27614 ] | |
Fix Version/s | 10.8 [ 26121 ] |
Fix Version/s | 10.12 [ 28320 ] | |
Fix Version/s | 10.11 [ 27614 ] |
Labels | optimizer-easy optimizer-feature |
Priority | Critical [ 2 ] | Major [ 3 ] |
Assignee | Sergei Petrunia [ psergey ] | Yuchen Pei [ JIRAUSER52627 ] |
Affects Version/s | N/A [ 14700 ] | |
Issue Type | Bug [ 1 ] | Task [ 3 ] |
Fix Version/s | 11.2 [ 28603 ] | |
Fix Version/s | 11.0 [ 28320 ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Summary | Use of DESC indexes is disabled for MIN/MAX optimization | Use DESC indexes for MIN/MAX optimization |
Fix Version/s | 11.3 [ 28565 ] | |
Fix Version/s | 11.2 [ 28603 ] |
Priority | Major [ 3 ] | Critical [ 2 ] |
Fix Version/s | 11.4 [ 29301 ] | |
Fix Version/s | 11.3 [ 28565 ] |
Fix Version/s | 11.5 [ 29506 ] | |
Fix Version/s | 11.4 [ 29301 ] |
Assignee | Yuchen Pei [ JIRAUSER52627 ] | Sergei Petrunia [ psergey ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Fix Version/s | 11.4 [ 29301 ] | |
Fix Version/s | 11.5 [ 29506 ] |
Assignee | Sergei Petrunia [ psergey ] | Yuchen Pei [ JIRAUSER52627 ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Link | This issue relates to MDEV-32732 [ MDEV-32732 ] |
Fix Version/s | 11.5 [ 29506 ] | |
Fix Version/s | 11.4 [ 29301 ] |
Assignee | Yuchen Pei [ JIRAUSER52627 ] | Sergei Petrunia [ psergey ] |
Status | Stalled [ 10000 ] | In Review [ 10002 ] |
Assignee | Sergei Petrunia [ psergey ] | Yuchen Pei [ JIRAUSER52627 ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Testing [ 10301 ] |
Assignee | Yuchen Pei [ JIRAUSER52627 ] | Lena Startseva [ JIRAUSER50478 ] |
Fix Version/s | 11.4 [ 29301 ] | |
Fix Version/s | 11.5 [ 29506 ] |
Assignee | Lena Startseva [ JIRAUSER50478 ] | Yuchen Pei [ JIRAUSER52627 ] |
Status | In Testing [ 10301 ] | Stalled [ 10000 ] |
Fix Version/s | 11.4.1 [ 29523 ] | |
Fix Version/s | 11.4 [ 29301 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Link | This issue causes TODO-4495 [ TODO-4495 ] |
Link | This issue causes TODO-4495 [ TODO-4495 ] |
Link | This issue is part of TODO-4495 [ TODO-4495 ] |
Labels | optimizer-easy optimizer-feature | Preview_11.4 optimizer-easy optimizer-feature |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 36730 ] |
Remote Link | This issue links to "Page (MariaDB Confluence)" [ 36730 ] |
I don't know what it will take to enable it, but it doesn't appear to be as simple as removing that if – having done so locally, I ran a quick set of tests and it returned quite a few failures. I can't say whether they genuinely relate to DESC indexes or just reveal some old problems, known or not, but they would certainly need to be investigated at least. So, given the release schedule, it may be safer to keep it as is now and, if at all needed, create a separate task for 10.9 about using DESC indexes in the optimizations. Or converting this item into such a task.
However, there are at least some effects of the disabled optimization which can come as a surprise. For example, this
returns
preview-10.8-MDEV-13756-desc-indexes c10e10c6
0.1234
I can't raise it to a bug level since it relies on float comparison which is not to be relied upon, but looking at existing MTR tests, for "normal" ascending indexes it is assumed that it will return the bigger value. Thus a surprise.