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
-
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.