mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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.
32 lines
725 B
Plaintext
32 lines
725 B
Plaintext
--source include/not_embedded.inc
|
|
--source include/have_innodb.inc
|
|
create table t1
|
|
(
|
|
pk1 int not null,
|
|
pk2 int not null,
|
|
key1 int not null,
|
|
key2 int not null,
|
|
key (key1),
|
|
key (key2),
|
|
primary key (pk1, pk2)
|
|
)engine=Innodb;
|
|
|
|
--disable_query_log
|
|
let $1=1000;
|
|
while ($1)
|
|
{
|
|
eval insert into t1 values (1+$1/10,$1 mod 100,$1,$1/100);
|
|
dec $1;
|
|
}
|
|
--enable_query_log
|
|
analyze table t1;
|
|
|
|
set optimizer_trace="enabled=on";
|
|
set @tmp_index_merge_ror_cpk=@@optimizer_switch;
|
|
set optimizer_switch='extended_keys=off';
|
|
explain select * from t1 where pk1 != 0 and key1 = 1;
|
|
select * from information_schema.OPTIMIZER_TRACE;
|
|
drop table t1;
|
|
set @@optimizer_switch= @tmp_index_merge_ror_cpk;
|
|
set optimizer_trace="enabled=off";
|