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

Slow EXPLAIN SELECT ... WHERE col IN (const1,const2,(subquery))

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
    • 10.3.14, 10.4.4
    • Optimizer
    • None

    Description

      I run this script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      INSERT INTO t1 SELECT * FROM t1;
      EXPLAIN SELECT * FROM t1 WHERE a IN (1,2,(SELECT MAX(a) FROM t1));
      

      +------+-------------+-------+------+---------------+------+---------+------+--------+-------------+
      | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows   | Extra       |
      +------+-------------+-------+------+---------------+------+---------+------+--------+-------------+
      |    1 | PRIMARY     | t1    | ALL  | NULL          | NULL | NULL    | NULL | 328184 | Using where |
      |    2 | SUBQUERY    | t1    | ALL  | NULL          | NULL | NULL    | NULL | 328144 |             |
      +------+-------------+-------+------+---------------+------+---------+------+--------+-------------+
      2 rows in set (6.69 sec)
      

      Notice, the EXPLAIN query was slow.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.