[MDEV-26939] support descending indexes for simple ORDER BY Created: 2021-10-29  Updated: 2023-03-21  Resolved: 2021-12-11

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Fix Version/s: 10.8.0

Type: Task Priority: Critical
Reporter: Sergei Golubchik Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
PartOf
is part of MDEV-13756 Implement descending index: KEY (a DE... Closed
Relates
relates to MDEV-26996 Support descending indexes in the ran... Closed

 Description   

in cases like

CREATE TABLE t1 (a INT, b INT, INDEX (a DESC, b ASC));
...
SELECT * FROM t1 ORDER BY a DESC, b ASC;

In other cases descending indexes could be treated as disabled.



 Comments   
Comment by Sergei Golubchik [ 2021-11-24 ]

ORDER BY seems to be working already:

sql/sql_select.cc

23449
    const ORDER::enum_order keypart_order= 
23450
      (key_part->key_part_flag & HA_REVERSE_SORT) ? 
23451
      ORDER::ORDER_DESC : ORDER::ORDER_ASC;
23452
    /* set flag to 1 if we can use read-next on key, else to -1 */
23453
    flag= (order->direction == keypart_order) ? 1 : -1;

Generated at Thu Feb 08 09:49:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.