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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • None
    • None

    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);

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            igor Igor Babaev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 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.