[MDEV-23677] Optimizer trace: remove print out with "no predicate for first keypart" Created: 2020-09-05  Updated: 2021-03-23  Resolved: 2021-03-18

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Fix Version/s: 10.6.0

Type: Task Priority: Critical
Reporter: Sergei Petrunia Assignee: Sergei Petrunia
Resolution: Fixed Votes: 0
Labels: optimizer_trace


 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.



 Comments   
Comment by Sergei Petrunia [ 2021-03-18 ]

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.

Comment by Sergei Petrunia [ 2021-03-18 ]

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.

Generated at Thu Feb 08 09:24:12 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.