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