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

LP:938131 - Subquery materialization is not used in CREATE TABLE SELECT

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      Using mariadb-5.3 create and populate table t1,t2 with the following commands:

      CREATE TABLE t1(a int);
      INSERT INTO t1 values(1),(2);
      CREATE TABLE t2(a int);
      INSERT INTO t2 values(1),(2);

      Then check that the following query uses subquery materialization:
      SELECT * FROM t1 WHERE a IN (SELECT * FROM t2 GROUP BY a HAVING a > 1);

      MariaDB [test]> EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT * FROM t2 GROUP BY a HAVING a > 1);
      ---------------------------------------------------------------------------------------------+

      id select_type table type possible_keys key key_len ref rows Extra

      ---------------------------------------------------------------------------------------------+

      1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
      1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 test.t1.a 1  
      2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using temporary

      ---------------------------------------------------------------------------------------------+

      In debugger check that materialization is not used for :

      CREATE TABLE t3 SELECT * FROM t1 WHERE a IN (SELECT * FROM t2 GROUP BY a HAVING a > 1);

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment -

            Re: Subquery materialization is not used in CREATE TABLE SELECT
            Fix released with 5.3.5-ga.

            Show
            elenst Elena Stepanova added a comment - Re: Subquery materialization is not used in CREATE TABLE SELECT Fix released with 5.3.5-ga.
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 938131

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 938131

              People

              • Assignee:
                psergey Sergei Petrunia
                Reporter:
                igor Igor Babaev
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: