[MDEV-22191] Range access is not picked when index_merge_sort_union is turned off Created: 2020-04-08  Updated: 2020-05-29  Resolved: 2020-04-13

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5
Fix Version/s: 5.5.68, 10.1.45, 10.2.32, 10.3.23, 10.4.13, 10.5.3

Type: Bug Priority: Major
Reporter: Varun Gupta (Inactive) Assignee: Varun Gupta (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-22174 Assertion `cost > 0.0' failed in adju... Closed
Relates
relates to MDEV-22160 SIGSEGV in st_join_table::save_explai... Closed
relates to MDEV-21932 A fast plan with ROR index-merge is ... Closed

 Description   

CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

MariaDB [test]> SET OPTIMIZER_SWITCH="index_merge_sort_union=ON";
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> explain SELECT * FROM t1 WHERE a > 5;
+------+-------------+-------+-------+---------------+------+---------+------+------+--------------------------+
| id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra                    |
+------+-------------+-------+-------+---------------+------+---------+------+------+--------------------------+
|    1 | SIMPLE      | t1    | range | a             | a    | 5       | NULL |    4 | Using where; Using index |
+------+-------------+-------+-------+---------------+------+---------+------+------+--------------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> SET OPTIMIZER_SWITCH="index_merge_sort_union=OFF";
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> explain SELECT * FROM t1 WHERE a > 5;
+------+-------------+-------+-------+---------------+------+---------+------+------+--------------------------+
| id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra                    |
+------+-------------+-------+-------+---------------+------+---------+------+------+--------------------------+
|    1 | SIMPLE      | t1    | index | a             | a    | 5       | NULL |   10 | Using where; Using index |
+------+-------------+-------+-------+---------------+------+---------+------+------+--------------------------+
1 row in set (0.00 sec)

So as you see above the plan changed from range scan to index scan when we turned off index_merge_sort_union, which is absolutely WRONG. This is because of the fix for MDEV-21932



 Comments   
Comment by Varun Gupta (Inactive) [ 2020-04-08 ]

Patch
http://lists.askmonty.org/pipermail/commits/2020-April/014241.html

Comment by Sergei Petrunia [ 2020-04-09 ]

Review input:
https://www.mail-archive.com/maria-developers@lists.launchpad.net/msg11749.html

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