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

Move all optimization query re-writes from the prepare phase into the optimizer phase

    XMLWordPrintable

Details

    Description

      Currently the function check_and_do_in_subquery_rewrite() is called at the prepare phase. Here's what the function does:

        /*
          If
            1) this join is inside a subquery (of any type except FROM-clause
               subquery) and
            2) we aren't just normalizing a VIEW
       
          Then perform early unconditional subquery transformations:
           - Convert subquery predicate into semi-join, or
           - Mark the subquery for execution using materialization, or
           - Perform IN->EXISTS transformation, or
           - Perform more/less ALL/ANY -> MIN/MAX rewriter
           - Substitute trivial scalar-context subquery with its value
       
      */

      All the the rewrites above are actually an optimization re-writes. Most of them transform the query tree into a form that cannot be converted into a proper equivalent SQL query. This prevents usage of an external SQL parser after the prepare stage if any of such transformation has been performed.
      From architectural point of view doing such re-writes in the middle of the prepare stage is also not a proper solution because some of the transformation may be rejected at the optimization stage.

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              igor Igor Babaev
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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