[MDEV-5197] Feature Request: optimize away LIKE '%%' Created: 2013-10-27  Updated: 2015-10-30

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Federico Razzoli Assignee: Unassigned
Resolution: Unresolved Votes: 2
Labels: optimizer


 Description   

Some scripts compose SQL queries without checking if some input fields are empty. As a result, they can produce queries containing LIKE '%%'. This clause does not appear to be optimized away:

MariaDB [test]> EXPLAIN EXTENDED SELECT c FROM t WHERE c LIKE '%%';
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
| id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra       |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
|    1 | SIMPLE      | t     | ALL  | NULL          | NULL | NULL    | NULL | 5 |   100.00 | Using where |
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
1 row in set, 1 warning (0.05 sec)
 
Note (Code 1003): select `test`.`t`.`c` AS `c` from `test`.`t` where (`test`.`t`.`c` like '%%')


Generated at Thu Feb 08 07:02:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.