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

Move subquery rewrites from JOIN::prepare into JOIN::optimize

    XMLWordPrintable

Details

    Description

      Currently some of the subquery rewrites are done in check_and_do_in_subquery_rewrites().

      This function is called from

      • JOIN::prepare() // the "primary" call
      • Item_exists_subselect::exists2in_processor // the secondary

      This task is about moving subquery rewrites from JOIN::prepare() phase into JOIN::optimize().

      check_and_do_in_subquery_rewrites() does several rewrites:

       - 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 rewrite
       - Substitute trivial scalar-context subquery with its value
      

      Note that for semi-joins, check_and_do_in_subquery_rewrites() doesn't actually do the rewrites. It checks the condition and adds the subquery into SELECT_LEX::sj_subselects.

      The actual conversion happens in JOIN::optimize_inner():

        if (select_lex->first_cond_optimization)
        {
          /* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
          if (convert_join_subqueries_to_semijoins(this))
            DBUG_RETURN(1); /* purecov: inspected */
          /* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
          select_lex->update_used_tables();
        }
      

      Attachments

        Issue Links

          Activity

            People

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