Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-5197

Feature Request: optimize away LIKE '%%'

    Details

    • Type: Task
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Fix Version/s: 10.1
    • Component/s: None
    • Labels:

      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 '%%')
      

        Gliffy Diagrams

          Attachments

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                Unassigned
                Reporter:
                f_razzoli Federico Razzoli
              • Votes:
                2 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: