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

Feature Request: optimize away LIKE '%%'

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • None
    • None

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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.