create table t1 ( a int, b int, c int, index(a), index(b));
insert into t1 select seq, seq, seq from seq_1_to_10000;


MariaDB [test]> explain select * from t1 where a < 200;
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra                 |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|    1 | SIMPLE      | t1    | range | a             | a    | 5       | NULL | 199  | Using index condition |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
1 row in set (0.001 sec)

mariadb [test]> explain select * from t1 where a < 200 order by a limit 1;
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra                 |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|    1 | SIMPLE      | t1    | range | a             | a    | 5       | NULL | 199  | Using index condition |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
1 row in set (0.001 sec)


explain select * from t1 where a < 5000 order by a limit 1;
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra                 |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|    1 | SIMPLE      | t1    | range | a             | a    | 5       | NULL | 199  | Using index condition |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
1 row in set (0.001 sec)

MariaDB [test]> explain select * from t1 where a < 5000 order by a limit 1;
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra                 |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|    1 | SIMPLE      | t1    | range | a             | a    | 5       | NULL | 4999 | Using index condition |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
1 row in set (0.001 sec)

MariaDB [test]> explain select * from t1 where a < 9000 order by a limit 1;
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra                 |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|    1 | SIMPLE      | t1    | range | a             | a    | 5       | NULL | 8999 | Using index condition |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
1 row in set (0.002 sec)

MariaDB [test]> explain select * from t1 where a < 9000 and b<1000 order by a limit 1;
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
| id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra       |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
|    1 | SIMPLE      | t1    | range | a,b           | a    | 5       | NULL | 8999 | Using where |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
1 row in set (0.010 sec)

MariaDB [test]> explain select * from t1 where a+0 < 9000 and b<1000 order by a limit 1;
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
| id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra       |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
|    1 | SIMPLE      | t1    | index | b             | a    | 5       | NULL | 10   | Using where |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
1 row in set (0.002 sec)


12.2.2


