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

Simplify query expressions over UNION/EXCEPT/INTERSECT

    XMLWordPrintable

Details

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

    Description

      The goal of this task is to simplify/optimize query expressions over UNION/EXCEPT/INTERSECT:

      1. convert UNION/EXCEPT/INTERSECT ALL into UNION/EXCEPT/INTERSECT DISTINCT

      whenever it's possible.
      E.g.

      select1 UNION ALL select2 UNION DISTINCT select3 UNION ALL select4
      =>
      select1 UNION DISTICT select2 UNION DISTINCT select3 UNION ALL select4
      

      2. Remove unnecessary brackets

      E.g.

      a)
      select1 UNION ALL (select2 UNION ALL select3)
      =>
      select1 UNION ALL select2 UNION ALL select3
       b)
      select1 UNION  (select2 EXCEPT select3)
      =>
      select1 UNION select2 EXCEPT select 3
      c)
      select1 EXCEPT  (select2 EXCEPT select3)
      =>
      select1 EXCEPT  select2 UNION select3
      

      3. Swap operands in order to omit brackets

      a)
       select1 UNION [ALL]  (select2 INTERSECT select3)
      =>
      select2 INTERSECT select3 UNION [ALL] select1
      b)
      select1 UNION ALL (select2 EXCEPT select3)
      =>
      select2 EXCEPT select3 UNION ALL select1
      

      In this task it is assumed that query expressions does not contain EXCEPT ALL / INTERSECT ALL (these operations are not implemented yet in MariaDB).

      Attachments

        Activity

          People

            igor Igor Babaev
            igor Igor Babaev
            Votes:
            0 Vote for this issue
            Watchers:
            7 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.