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

When executing two logically equivalent SQL statements, unexpected Performance Difference Between INNER JOIN and LEFT/RIGHT JOIN with Complex Conditions

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.11.11
    • 11.8
    • Optimizer
    • None
    • MariaDB [database1]> select version();
      +--------------------------+
      | version() |
      +--------------------------+
      | 10.11.11-MariaDB-ubu2204 |
      +--------------------------+
      1 row in set (0.000 sec)

    Description

      When I executed two logically equivalent query SQLs, I incurred almost 43 times the time overhead gap.

      Refer to tables_backup.sql for table1 and table2.

      MariaDB [database1]> SELECT DISTINCT table1.value
      FROM  table1
      INNER JOIN table2 ON ((((LOG(COT((('0.5178156142304718')AND(1390707540)))))>=(table2.id)))REGEXP(table2.id));
      Empty set (0.027 sec)
       
      MariaDB [database1]> SELECT DISTINCT table1.value
      FROM table1
      LEFT JOIN table2 ON ((((LOG(COT((('0.5178156142304718')AND(1390707540)))))>=(table2.id)))REGEXP(table2.id))
      INTERSECT
      SELECT DISTINCT table1.value
      FROM table1
      RIGHT JOIN table2 ON ((((LOG(COT((('0.5178156142304718')AND(1390707540)))))>=(table2.id)))REGEXP(table2.id));
      Empty set (1.178 sec)
      

      Attachments

        1. screenshot-1.png
          123 kB
          Ce Lyu
        2. tables_backup.sql
          311 kB
          Ce Lyu

        Activity

          People

            psergei Sergei Petrunia
            Ce Lyu Ce Lyu
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.