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

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

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.1, 10.2, 10.3, 10.4
    • Fix Version/s: 10.3.14, 10.4.4
    • Component/s: Optimizer
    • Labels:
      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

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: