Commit graph

7 commits

Author SHA1 Message Date
Sergei Petrunia
32692140e1 MDEV-27306: SET STATEMENT optimizer_trace=1 Doesn't save the trace
In mysql_execute_command(), move optimizer trace initialization to be
after run_set_statement_if_requested() call.

Unfortunately, mysql_execute_command() code uses "goto error" a lot, and
this means optimizer trace code cannot use RAII objects. Work this around
by:
- Make Opt_trace_start a non-RAII object, add init() method.
- Move the code that writes the top-level object and array into
  Opt_trace_start::init().
2021-12-19 17:19:02 +03:00
Sergei Petrunia
b9a45ba40f MDEV-23645: Optimizer trace: print conditions after substitute_for_best_equal_field
Print the conditions for WHERE, HAVING, and ON.
2021-03-19 17:37:38 +03:00
Monty
a24d0926b9 Second stage of optimizer_trace optimizations
- Move testing of my_writer to inline functions to avoid calls
- Made more functions inline. Especially thd->thread_started()
  is now very optimized!
- Moved Opt_trace_stmt classe to opt_trace_context.h to get critical
  functions inline
2020-03-09 13:52:40 +02:00
Varun Gupta
71c57bcf8f Moved the function trace_plan_prefix to the optimizer trace file
Also added comments for trace_plan_prefix and the class Json_writer_temp_disable
2019-09-11 04:32:40 +05:30
Varun Gupta
7b988e5ceb MDEV-20444: More information regarding access of a table to be printed inside the optimizer_trace
Added:
      1) estimated_join_cardinality
      2) best_chosen_access_method for a table
      3) best_join_order
2019-09-11 04:32:40 +05:30
Varun Gupta
9cb55143ac Minor cleanup in the optimizer trace code.
More test coverage added for the optimizer trace.
2019-02-18 17:11:20 +05:30
Varun Gupta
be8709eb7b MDEV-6111 Optimizer Trace
This task involves the implementation for the optimizer trace.

This feature produces a trace for any SELECT/UPDATE/DELETE/,
which contains information about decisions taken by the optimizer during
the optimization phase (choice of table access method, various costs,
transformations, etc). This feature would help to tell why some decisions were
taken by the optimizer and why some were rejected.

Trace is session-local, controlled by the @@optimizer_trace variable.
To enable optimizer trace we need to write:
   set @@optimizer_trace variable= 'enabled=on';

To display the trace one can run:
   SELECT trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;

This task also involves:
    MDEV-18489: Limit the memory used by the optimizer trace
    introduces a switch optimizer_trace_max_mem_size which limits
    the memory used by the optimizer trace. This was implemented by
    Sergei Petrunia.
2019-02-13 11:52:36 +05:30