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

t0 CROSS JOIN t1 ON FALSE when INTERSECTed with another query should perform no action

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 11.7.2
    • 10.11, 11.4, 11.8
    • None
    • None
    • docker pull mariadb:latest

    Description

      Dear MariaDB Developer:

      I find a performance bug as follow:

      In the case of q1 INTERSECT q2, when q2 takes the form of t0 CROSS JOIN t1 ON FALSE, this operation should not require physical reads. Since t0 CROSS JOIN t1 ON FALSE by definition always returns an empty set, the intersection q1 INTERSECT q2 must logically yield an empty result without needing to execute the underlying query.

      MariaDB [fuzz]> use information_schema;
      MariaDB [information_schema]> FLUSH STATUS;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [information_schema]> SELECT * FROM TABLES CROSS JOIN VIEWS ON FALSE;
      Empty set (0.002 sec)
       
      MariaDB [information_schema]> SHOW SESSION STATUS LIKE 'Handler_read%';
      +--------------------------+-------+
      | Variable_name            | Value |
      +--------------------------+-------+
      | Handler_read_first       | 0     |
      | Handler_read_key         | 0     |
      | Handler_read_last        | 0     |
      | Handler_read_next        | 0     |
      | Handler_read_prev        | 0     |
      | Handler_read_retry       | 0     |
      | Handler_read_rnd         | 0     |
      | Handler_read_rnd_deleted | 0     |
      | Handler_read_rnd_next    | 0     |
      +--------------------------+-------+
      9 rows in set (0.002 sec)
       
      MariaDB [information_schema]> FLUSH STATUS;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [information_schema]>  SELECT * FROM TABLES CROSS JOIN VIEWS ON TRUE INTERSECT SELECT * FROM TABLES CROSS JOIN VIEWS ON FALSE;
      Empty set (4.175 sec)
       
      MariaDB [information_schema]> SHOW SESSION STATUS LIKE 'Handler_read%';
      +--------------------------+--------+
      | Variable_name            | Value  |
      +--------------------------+--------+
      | Handler_read_first       | 0      |
      | Handler_read_key         | 152    |
      | Handler_read_last        | 0      |
      | Handler_read_next        | 0      |
      | Handler_read_prev        | 0      |
      | Handler_read_retry       | 0      |
      | Handler_read_rnd         | 0      |
      | Handler_read_rnd_deleted | 0      |
      | Handler_read_rnd_next    | 146836 |
      +--------------------------+--------+
      9 rows in set (0.001 sec)
      

      Thank you for your time and attention to this issue. I greatly appreciate your assistance and look forward to hearing your thoughts.

      Best regards,

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jinhui lai jinhui lai
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.