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

same values in `IN` set vs equal comparison produces the different performance

    XMLWordPrintable

Details

    Description

      The following query returns a different execution plan and a significantly different execution time. The following repro is exactly same as the initial bug report in MENT.

       
      MariaDB [sysbench]> explain select a.* from sysbench.sbtest1 a left join sysbench2.sbtest1 as b on a.id = b.id where a.id = 1000 order by b.id;
      +------+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
      | id   | select_type | table | type  | possible_keys | key     | key_len | ref   | rows | Extra       |
      +------+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
      |    1 | SIMPLE      | a     | const | PRIMARY       | PRIMARY | 4       | const | 1    |             |
      |    1 | SIMPLE      | b     | const | PRIMARY       | PRIMARY | 4       | const | 1    | Using index |
      +------+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
      2 rows in set (0.000 sec)
       
      MariaDB [sysbench]> explain select a.* from sysbench.sbtest1 a left join sysbench2.sbtest1 as b on a.id = b.id where a.id in ( 1000, 1000) order by b.id;
      +------+-------------+-------+--------+---------------+---------+---------+---------------+------+----------------------------------------------+
      | id   | select_type | table | type   | possible_keys | key     | key_len | ref           | rows | Extra                                        |
      +------+-------------+-------+--------+---------------+---------+---------+---------------+------+----------------------------------------------+
      |    1 | SIMPLE      | a     | range  | PRIMARY       | PRIMARY | 4       | NULL          | 1    | Using where; Using temporary; Using filesort |
      |    1 | SIMPLE      | b     | eq_ref | PRIMARY       | PRIMARY | 4       | sysbench.a.id | 1    | Using index                                  |
      +------+-------------+-------+--------+---------------+---------+---------+---------------+------+----------------------------------------------+
      2 rows in set (0.000 sec)
      
      

      Attachments

        Issue Links

          Activity

            People

              oleg.smirnov Oleg Smirnov
              allen.lee@mariadb.com Allen Lee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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