Optimizer Debugging With GDB

You are viewing an old version of this article. View the current version here.

Some useful things for debugging optimizer code with gdb.

Useful print functions

  • Attachment 'dbug_print_item' not found prints the contents of Attachment 'Item' not found object into a buffer and returns pointer to it.
  • Attachment 'dbug_print_sel_arg' not found prints an individual Attachment 'SEL_ARG' not found object (NOT the whole graph or tree) and returns pointer to the buffer holding the printout.

Printing the Optimizer Trace

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

Printing Current Partial Join Prefix

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

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.