1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Make trace.add() usage uniform

- Before any multiple add() calls, always use (if trace_started()).
- Add unlikely() around all tests of trace_started().
- Change trace.add(); trace.add(); to trace.add().add();
- When trace.add() goes over several line, use the following formating:
trace.
 add(xxx).
 add(yyy).
 add(zzz);

This format was choosen after a discussion between Sergei Petrunia and
me as it looks similar indepedent if 'trace' is an object or a
pointer. It also more suitable for an editors auto-indentation.

Other things:

Added DBUG_ASSERT(thd->trace_started()) to a few functions that should
only be called if trace is enabled.

"use_roworder_index_merge: true" changed to "use_sort_index_merge: false"
As the original output was often not correct.
Also fixed the related 'cause' to be correct.

In best_access_path() print the cost (and number of rows) before
checking if it the plan should be used. This removes the need to print
the cost in two places.

Changed a few "read_time" tags to "cost".
This commit is contained in:
Monty
2022-01-20 15:49:01 +02:00
committed by Sergei Petrunia
parent ec6aa2829a
commit 766bae2b31
11 changed files with 429 additions and 250 deletions

View File

@@ -1014,11 +1014,12 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count,
{
Json_writer_object wrapper(thd);
Json_writer_object find_trace(thd, "best_splitting");
find_trace.add("table", best_table->alias.c_ptr());
find_trace.add("key", best_table->key_info[best_key].name);
find_trace.add("record_count", record_count);
find_trace.add("cost", spl_plan->cost);
find_trace.add("unsplit_cost", spl_opt_info->unsplit_cost);
find_trace.
add("table", best_table->alias.c_ptr()).
add("key", best_table->key_info[best_key].name).
add("record_count", record_count).
add("cost", spl_plan->cost).
add("unsplit_cost", spl_opt_info->unsplit_cost);
}
memcpy((char *) spl_plan->best_positions,
(char *) join->best_positions,
@@ -1047,10 +1048,14 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count,
startup_cost= record_count * spl_plan->cost;
records= (ha_rows) (records * spl_plan->split_sel);
Json_writer_object trace(thd, "lateral_derived");
trace.add("startup_cost", startup_cost);
trace.add("splitting_cost", spl_plan->cost);
trace.add("records", records);
if (unlikely(thd->trace_started()))
{
Json_writer_object trace(thd, "lateral_derived");
trace.
add("startup_cost", startup_cost).
add("splitting_cost", spl_plan->cost).
add("records", records);
}
}
else
startup_cost= spl_opt_info->unsplit_cost;