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

Slow SELECT with two joins + where on 3rd table + group on 1st table date

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • Optimizer
    • None

    Description

      I noticed that one of my SELECT queries takes ~18 seconds. I started debugging it and prepared a minimal test case: a pretty simple SELECT over 3 tables (1500 rows in total) with 1 WHERE and 1 GROUP BY. That minimal SELECT still takes 10+ seconds.

      I think there may be some bug in SELECT optimization. I'm not
      export thought to fully understand the issue. I thought someone may want to take a look at it and consider optimizing MariaDB for such queries.

      SELECT date
      FROM aaa
      LEFT JOIN bbb ON (bbb.code = aaa.code)
      LEFT JOIN ccc ON (ccc.name = bbb.name)
      WHERE ccc.type = "foo"
      GROUP BY date;

      On MariaDB 10.4.22 used by my hosting provider it takes 13 seconds to execute about query.

      Attachments

        1. setup.sql
          30 kB
          Rafał Miłecki

        Activity

          People

            Unassigned Unassigned
            rmilecki Rafał Miłecki
            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.