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

Incorrect cost computation in best_access_path: record_count *= TIME_FOR_COMPARE

    XMLWordPrintable

Details

    Description

      As pointed out by monty :

      best_access_path doesn't multiply correctly:

      diff --git a/sql/sql_select.cc b/sql/sql_select.cc
      index 86f51917f50..dcf0281f60d 100644
      --- a/sql/sql_select.cc
      +++ b/sql/sql_select.cc
      @@ -8723,10 +8723,10 @@ best_access_path(JOIN      *join,
             if (!cause)
               trace_access_idx.add("rows", records).add("cost", tmp);
       
      -      if (tmp + 0.0001 < best_time - records/TIME_FOR_COMPARE)
      +      if (tmp + 0.0001 < best_time - (records*record_count)/TIME_FOR_COMPARE)
             {
               trace_access_idx.add("chosen", true);
      -        best_time= COST_ADD(tmp, records/TIME_FOR_COMPARE);
      +        best_time= COST_ADD(tmp, (records*record_count)/TIME_FOR_COMPARE);
               best= tmp;
               best_records= records;
               best_key= start_key;
      

      (running mtr with this in 10.6 produces one changed explain in subselect_sj2_mat. It is not clear what that shows).

      Attachments

        Activity

          People

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