Commit graph

16 commits

Author SHA1 Message Date
Sergei Golubchik
01a0d739c8 MDEV-24975 Server consumes extra 4G memory upon querying INFORMATION_SCHEMA.OPTIIMIZER_TRACE
if a query used no fields from an I_S table, we were creating a temp
table with one, first, field (as a table cannot have zero fields),
with its length truncated to 1.

Now - force also this dummy field to be a normal field, not a BLOB
2021-03-08 15:00:45 +01:00
Varun Gupta
cc0dca3663 MDEV-22910: SIGSEGV in Opt_trace_context::is_started & SIGSEGV in Json_writer::add_table_name (on optimized builds)
Make sure to initialize members of TABLE::reginfo when TABLE::init is called. In this case the problem
was that table->reginfo.join_tab was set for the SELECT query and then was reused by the UPDATE query.
This case occurred only when the SELECT query had a degenerate join.
2020-06-30 18:29:02 +05:30
Varun Gupta
4c3cbe2392 MDEV-22665: Print ranges in the optimizer trace created for non-indexed columns when optimizer_use_condition_selectivity >2
Now the optimizer trace shows the ranges constructed while getting estimates from EITS
2020-06-18 20:15:06 +05:30
Varun Gupta
6404645980 MDEV-21626: Optimizer misses the details about the picked join order
Added cost of sorting estimate to the optimizer trace
2020-06-04 20:03:22 +05:30
Marko Mäkelä
50f3a38e89 Add an end marker to a test 2020-05-04 18:31:30 +03:00
Sergei Petrunia
7bc6735736 MDEV-22401: Optimizer trace: multi-component range is not printed correctly
KEY_MULTI_RANGE::range_flag does not have correct flag bits for
per-endpoint flags (NEAR_MIN, NEAR_MAX, NO_MIN_RANGE, NO_MAX_RANGE).
It only has bits for flags that describe both endpoints.
So
- Document this.
- Switch optimizer trace to using {start|end}_key.flag values, instead.
  This fixes the bug.
- Switch records_in_column_ranges() to doing that too. (This used to
  work, because KEY_MULTI_RANGE::range_flag had correct flag value
  for the last key component, and EITS only uses one-component
  pseudo-indexes)
2020-04-29 16:31:16 +03:00
Sergei Petrunia
4a490d1a99 MDEV-6111: Optimizer Trace: add tracing for semi-join optimizations
Added:
- "semijoin_strategy_choice" element (actions in advance_sj_state(), name
  matches the name in MySQL)

- semijoin_table_pullout element.
2019-08-25 11:04:39 +03:00
Varun Gupta
4d5382504d MDEV-20349: Assertion `to_len >= 8' failed in convert_to_printable
Use convert_to_printable function to write only non-empty ranges to the optimizer trace
2019-08-16 16:49:12 +05:30
Marko Mäkelä
d7be886cb8 Fix main.opt_trace
This was broken in 2dbe472ed0
2019-08-14 10:32:52 +03:00
Sergei Petrunia
2dbe472ed0 Optimizer trace: print cost and #rows of the join prefix
The names rows_for_plan and cost_for_plan follow MySQL
Also added post-join-operation selectivity cost
2019-08-13 16:08:48 +03:00
Varun Gupta
8b576616b4 MDEV-19776: Assertion `to_len >= 8' failed in convert_to_printable with optimizer trace enabled
Introduced the convert_to_printable_required_length to return the correct length(taking into
consideration of dots in the case of error messages).
2019-06-20 12:03:32 +05:30
Varun
a0cb7551a4 MDEV-18880: Optimizer trace prints date in hexadecimal
Introduced a print_key_value function to makes sure that the trace prints data in readable format
for readable characters and the rest of the characters are printed as hexadecimal.
2019-06-11 15:44:58 +05:30
Varun Gupta
5e36f5dd00 MDEV-18741: Optimizer trace: multi-part key ranges are printed incorrectly
Changed the function append_range_all_keyparts to use sel_arg_range_seq_init / sel_arg_range_seq_next to produce ranges.
Also adjusted to print format for the ranges, now the ranges are printed as:
    (keypart1_min, keypart2_min,..)  OP (keypart1_name,keypart2_name, ..) OP (keypart1_max,keypart2_max, ..)

Also added more tests for range and index merge access for optimizer trace
2019-05-28 17:17:44 +05:30
Varun Gupta
0dc442ac61 MDEV-18942: Json_writer::add_bool: Conditional jump or move depends on uninitialised value upon fulltext search under optimizer trace
For keyuse of fulltext set the value for null_rejecting to FALSE
as we don't add NOT NULL keys for fulltext keyuses
2019-04-03 00:32:26 +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