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

Code get_best_combination() computes aggr_tables incorrectly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
    • Fix Version/s: 10.10
    • Component/s: Optimizer
    • Labels:
      None

      Description

      I've discovered this when investigating MDEV-23809.

      There is code get_best_combination that computes the number of aggregate tables:

         /*
          Additional plan nodes for postjoin tmp tables:
            1? + // For GROUP BY
            1? + // For DISTINCT
            1? + // For aggregation functions aggregated in outer query
                 // when used with distinct
            1? + // For ORDER BY
            1?   // buffer result
          Up to 2 tmp tables are actually used, but it's hard to tell exact number
          at this stage.
        */
        uint aggr_tables= (group_list ? 1 : 0) +
                          (select_distinct ?
                           (tmp_table_param.using_outer_summary_function ? 2 : 1) : 0) +
                          (order ? 1 : 0) +
             (select_options & (SELECT_BIG_RESULT | OPTION_BUFFER_RESULT) ? 1 : 0) ;
      

      We don't have specific examples yet, but we suspect it might be incorrect.

      One thing that was discovered is that tmp_table_param.using_outer_summary_function is set after this piece of code is executed.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergei Sergei Petrunia
              Reporter:
              psergei Sergei Petrunia
              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.