mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
be8709eb7b
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.
21 lines
685 B
Text
21 lines
685 B
Text
--source include/not_embedded.inc
|
|
set @tmp_opt_switch= @@optimizer_switch;
|
|
set optimizer_switch='index_merge_sort_intersection=on';
|
|
set optimizer_trace='enabled=on';
|
|
create table t0 (a int);
|
|
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
create table t1 (a int, b int, c int, filler char(100),
|
|
key(a), key(b), key(c));
|
|
insert into t1 select
|
|
A.a * B.a*10 + C.a*100,
|
|
A.a * B.a*10 + C.a*100,
|
|
A.a,
|
|
'filler'
|
|
from t0 A, t0 B, t0 C;
|
|
|
|
--echo This should use union:
|
|
explain select * from t1 where a=1 or b=1;
|
|
select * from information_schema.OPTIMIZER_TRACE;
|
|
drop table t0,t1;
|
|
set optimizer_trace="enabled=off";
|
|
set @@optimizer_switch= @tmp_opt_switch;
|