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

Transform OUTER JOIN to INNER JOIN in subqueries used with IN operator

    XMLWordPrintable

Details

    • Task
    • Status: In Review (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.4
    • None
    • None

    Description

      In TODO-4513 a customer noticed that their previous MySQL 5.5 simplified LEFT JOIN to INNER JOIN in the subquery from the test case below, whereas MariaDB did not.

      CREATE TABLE t1 (a INT, b INT);
      CREATE TABLE t2 (a INT, b INT);
      CREATE TABLE t3 (a INT, b INT);
       
      INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
      INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
      INSERT INTO t3 VALUES (1,1), (2,2), (3,3);
       
      set optimizer_switch='semijoin=off';
       
      EXPLAIN EXTENDED SELECT 1
      FROM t1
      WHERE a = 1 AND b IN
            (SELECT t3.a
              FROM t2 LEFT JOIN t3 ON t3.b = t2.a
              WHERE t2.b = 1);
       
      DROP TABLE t1, t2, t3;
      

      While investigating the difference we have found out that MySQL's logic of processing subqueries is different, and that allows them to simplify the join. Is it possible to implement the simplification for MariaDB?

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            oleg.smirnov Oleg Smirnov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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