Some useful things for debugging optimizer code with gdb.
dbug_print_item() prints the contents of an Item object into a buffer and returns pointer to it. dbug_print_sel_arg() prints an individual SEL_ARG object (NOT the whole graph or tree) and returns pointer to the buffer holding the printout. dbug_print_table_row prints the current row buffer of the given table. dbug_print_XX functions for various data structures The optimizer trace is collected as plain text. One can print the contents of the trace collected so far as follows:
printf "%s\n", thd->opt_trace->current_trace->current_json->output.str.Ptr
best_access_path() is a function that adds another table to the join prefix.
When in or around that function, the following can be useful:
A macro to print the join prefix already constructed:
define bap_print_prefix
set $i=0
while ($i < idx)
p join->positions[$i++].table->table->alias.Ptr
end
end
© 2023 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/optimizer-debugging-with-gdb/