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

Optimizer trace: remove print out with "no predicate for first keypart"

Details

    Description

      For joins, best_access_path object can have printouts like this:

              {
                "access_type": "ref",
                "index": "PRIMARY",
                "rows": 1.79769e308,
                "cost": 1.79769e308,
                "chosen": false,
                "cause": "no predicate for first keypart"
              },
      

      I think these should be removed as they don't have any value.

      Attachments

        Activity

          diff --git a/sql/sql_select.cc b/sql/sql_select.cc
          index a6aee4db3416..011dd26d42d7 100644
          --- a/sql/sql_select.cc
          +++ b/sql/sql_select.cc
          @@ -7761,11 +7761,7 @@ best_access_path(JOIN      *join,
                       tmp= COST_MULT(tmp, record_count);
                     }
                     else
          -          {
          -            if (!(found_part & 1))
          -              cause= "no predicate for first keypart";
                       tmp= best_time;                    // Do nothing
          -          }
                   }
           
                   tmp= COST_ADD(tmp, s->startup_cost);
          

          Well, this will just change

                     "cause": "no predicate for first keypart"
          

          to

                     "cause": "cost"
          

          but will still print the index being considered (actually not).

          I've tried to make the code to avoid printing the whole object, i.e.

                      {
                          "access_type": "ref",
                          "index": "PRIMARY",
                          "rows": 1.79769e308,
                          "cost": 1.79769e308,
                          "chosen": false,
                          "cause": "no predicate for first keypart"   
                      },
          

          but this is hard to do as ref access code has some side effects (changes in found_constraint and Loose_scan_opt). Considering this, it's better not to make this change now.

          psergei Sergei Petrunia added a comment - diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a6aee4db3416..011dd26d42d7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7761,11 +7761,7 @@ best_access_path(JOIN *join, tmp= COST_MULT(tmp, record_count); } else - { - if (!(found_part & 1)) - cause= "no predicate for first keypart"; tmp= best_time; // Do nothing - } } tmp= COST_ADD(tmp, s->startup_cost); Well, this will just change "cause": "no predicate for first keypart" to "cause": "cost" but will still print the index being considered (actually not). I've tried to make the code to avoid printing the whole object, i.e. { "access_type": "ref", "index": "PRIMARY", "rows": 1.79769e308, "cost": 1.79769e308, "chosen": false, "cause": "no predicate for first keypart" }, but this is hard to do as ref access code has some side effects (changes in found_constraint and Loose_scan_opt). Considering this, it's better not to make this change now.

          On the other hand some printouts are misleading:

                            else /* (table->quick_key_parts[key] < max_key_part) */
                            {
                              trace_access_idx.add("chosen", true);
                              cause= "range uses less keyparts";
                            }
          

          and sometimes used_range_estimates is not printed when the reuse is happening.

          psergei Sergei Petrunia added a comment - On the other hand some printouts are misleading: else /* (table->quick_key_parts[key] < max_key_part) */ { trace_access_idx.add( "chosen" , true ); cause= "range uses less keyparts" ; } and sometimes used_range_estimates is not printed when the reuse is happening.

          People

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