mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge branch '10.5' into 10.6
This commit is contained in:
@ -83,7 +83,9 @@ analyze table t1;
|
||||
analyze table t2;
|
||||
|
||||
explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b;
|
||||
--disable_view_protocol
|
||||
select * from information_schema.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t1,t2,t0;
|
||||
|
||||
--echo #
|
||||
@ -110,7 +112,9 @@ INSERT INTO t1(a) SELECT a FROM t1;
|
||||
|
||||
analyze table t1;
|
||||
EXPLAIN SELECT DISTINCT a FROM t1;
|
||||
--disable_view_protocol
|
||||
select * from information_schema.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
@ -120,7 +124,9 @@ CREATE TABLE t1 (a INT, b INT, c int, d int, KEY(a,b,c,d));
|
||||
INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (1,0,1,1), (3,2,3,3), (4,5,4,4);
|
||||
ANALYZE TABLE t1;
|
||||
EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a;
|
||||
--disable_view_protocol
|
||||
select * from information_schema.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t1 (id INT NOT NULL, a DATE, KEY(id,a));
|
||||
@ -134,9 +140,13 @@ INSERT INTO t1 values (1,'2001-01-01'),(1,'2001-01-02'),
|
||||
(4,'2001-01-03'),(4,'2001-01-04');
|
||||
set optimizer_trace='enabled=on';
|
||||
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id;
|
||||
--disable_view_protocol
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id;
|
||||
--disable_view_protocol
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
@ -165,7 +175,9 @@ update t1 set b=2 where pk between 0 and 20;
|
||||
analyze table t1;
|
||||
set optimizer_trace='enabled=on';
|
||||
explain select * from t1 where a=1 and b=2 order by c limit 1;
|
||||
--disable_view_protocol
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t1,ten,one_k;
|
||||
|
||||
--echo #
|
||||
@ -191,15 +203,21 @@ analyze table t3;
|
||||
--echo # table t2 should be eliminated
|
||||
explain
|
||||
select t1.a from t1 left join t2 on t1.a=t2.a;
|
||||
--disable_view_protocol
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
|
||||
--echo # no tables should be eliminated
|
||||
explain select * from t1 left join t2 on t2.a=t1.a;
|
||||
--disable_view_protocol
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
|
||||
--echo # multiple tables are eliminated
|
||||
explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and t3.a=t1.a;
|
||||
--disable_view_protocol
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t0, t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
@ -224,7 +242,9 @@ analyze table t1,t10;
|
||||
|
||||
set optimizer_trace='enabled=on';
|
||||
explain extended select * from t1 where a in (select pk from t10);
|
||||
--disable_view_protocol
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t0,t1,t11,t10,t12,t2;
|
||||
|
||||
--echo #
|
||||
@ -250,7 +270,9 @@ set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables= PREFERABLY;
|
||||
set optimizer_trace='enabled=on';
|
||||
explain select * from t1 where pk = 2 and a=5 and b=1;
|
||||
--disable_view_protocol
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
set @@use_stat_tables= @save_use_stat_tables;
|
||||
drop table t0,t1;
|
||||
@ -329,7 +351,9 @@ alter table t0 add key(a);
|
||||
|
||||
set optimizer_trace=1;
|
||||
explain delete from t0 where t0.a<3;
|
||||
--disable_view_protocol
|
||||
select * from information_schema.optimizer_trace;
|
||||
--enable_view_protocol
|
||||
drop table ten,t0;
|
||||
set optimizer_trace='enabled=off';
|
||||
|
||||
@ -346,7 +370,9 @@ alter table t0 add key(a);
|
||||
create table t1 like t0;
|
||||
insert into t1 select * from t0;
|
||||
explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3;
|
||||
--disable_view_protocol
|
||||
select * from information_schema.optimizer_trace;
|
||||
--enable_view_protocol
|
||||
drop table ten,t0,t1;
|
||||
set optimizer_trace='enabled=off';
|
||||
|
||||
@ -358,7 +384,9 @@ set optimizer_trace=1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
explain select * from (select rand() from t1)q;
|
||||
--disable_view_protocol
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t1;
|
||||
set optimizer_trace='enabled=off';
|
||||
|
||||
@ -373,6 +401,7 @@ create table t2(a int);
|
||||
insert into t2 values (1),(2),(3),(1),(2),(3),(1),(2),(3);
|
||||
set @save_optimizer_switch= @@optimizer_switch;
|
||||
explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_inner_2);
|
||||
--disable_view_protocol
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
|
||||
--echo # with Firstmatch, mostly for tracing fix_semijoin_strategies_for_picked_join_order
|
||||
@ -385,6 +414,7 @@ set optimizer_switch='materialization=on';
|
||||
explain select * from t1 t_outer_1,t2 t_outer_2 where t_outer_1.a in (select t_inner_1.a from t2 t_inner_2, t1 t_inner_1) and
|
||||
t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4);
|
||||
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
set @@optimizer_switch= @save_optimizer_switch;
|
||||
drop table t1,t2;
|
||||
|
||||
@ -413,11 +443,14 @@ create table t1 ( a int, b int, key a_b(a,b));
|
||||
insert into t1 select a,a from one_k;
|
||||
set optimizer_trace='enabled=on';
|
||||
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
explain select * from t1 force index (a_b) where a=2 and b=4;
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
|
||||
explain select * from t1 where a >= 900 and b between 10 and 20;
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
|
||||
drop table t0,t1;
|
||||
|
||||
@ -426,7 +459,10 @@ create table t1 (start_date date, end_date date, filler char(100), key(start_dat
|
||||
insert into t1 select date_add(now(), interval a day), date_add(now(), interval (a+7) day), 'data' from one_k;
|
||||
--enable_warnings
|
||||
explain select * from t1 force index(start_date) where start_date >= '2019-02-10' and end_date <'2019-04-01';
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t1,one_k;
|
||||
|
||||
create table ten(a int);
|
||||
@ -441,7 +477,10 @@ create table t1 (
|
||||
|
||||
insert into t1 select a,a, a,a from ten;
|
||||
explain select * from t1 force index(a_b_c) where a between 1 and 4 and b < 50;
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table ten,t1;
|
||||
|
||||
--echo # Ported test from MYSQL for ranges involving Binary column
|
||||
@ -450,11 +489,14 @@ CREATE TABLE t1(i INT PRIMARY KEY, b BINARY(16), INDEX i_b(b));
|
||||
INSERT INTO t1 VALUES (1, x'D95B94336A9946A39CF5B58CFE772D8C');
|
||||
INSERT INTO t1 VALUES (2, NULL);
|
||||
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
EXPLAIN SELECT * FROM t1 WHERE b IN (0xD95B94336A9946A39CF5B58CFE772D8C);
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
|
||||
EXPLAIN SELECT * FROM t1 WHERE b IS NULL;
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
|
||||
drop table t1;
|
||||
|
||||
@ -467,6 +509,8 @@ INSERT INTO t1 VALUES (1, 'ab\n');
|
||||
INSERT INTO t1 VALUES (2, NULL);
|
||||
set optimizer_trace=1;
|
||||
EXPLAIN SELECT * FROM t1 WHERE b='ab\n';
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
|
||||
ALTER TABLE t1 modify column b BINARY(10) AFTER i;
|
||||
@ -510,6 +554,7 @@ insert into t1 select date_add(now(), interval a day), date_add(now(), interval
|
||||
--enable_warnings
|
||||
explain format=json select * from t1 force index(start_date) where start_date >= '2019-02-10' and end_date <'2019-04-01';
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t1, t0, one_k;
|
||||
|
||||
--echo #
|
||||
@ -541,13 +586,19 @@ set optimizer_trace=1;
|
||||
--echo # but for joins using condition selectivity it is not as trivial. So,
|
||||
--echo # now we are printing it)
|
||||
explain select * from t0 A, one_k B where A.a<5 and B.a<800;
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
|
||||
set join_cache_level=@tmp_jcl;
|
||||
|
||||
--echo # This shows post-join selectivity
|
||||
explain select * from t0 A, one_k B where A.a=B.b and B.a<800;
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t0, one_k;
|
||||
|
||||
--echo #
|
||||
@ -559,7 +610,10 @@ insert into t1 values ('foo'), ('bar');
|
||||
|
||||
EXPLAIN SELECT * FROM t1 WHERE a= REPEAT('a', 0);
|
||||
SELECT * FROM t1 WHERE a= REPEAT('a', 0);
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
@ -577,7 +631,10 @@ insert into t3 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
|
||||
explain
|
||||
select * from t3 where (a,a) in (select t1.a, t2.a from t1, t2 where t1.b=t2.b);
|
||||
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.semijoin_table_pullout')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
|
||||
drop table t1,t2,t3;
|
||||
|
||||
@ -589,7 +646,10 @@ create table t1 (kp1 int, kp2 int, key(kp1, kp2));
|
||||
insert into t1 values (1,1),(1,5),(5,1),(5,5);
|
||||
set optimizer_trace=1;
|
||||
select * from t1 force index(kp1) where (kp1=2 and kp2 >=4);
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
@ -603,7 +663,10 @@ INSERT INTO t2 SELECT seq, seq from seq_1_to_100;
|
||||
|
||||
SET OPTIMIZER_TRACE=1;
|
||||
EXPLAIN SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t2.b;
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
@ -615,12 +678,15 @@ CREATE TABLE t1(a INT, b INT);
|
||||
INSERT INTO t1 SELECT seq, seq from seq_1_to_100;
|
||||
SET optimizer_trace=1;
|
||||
ANALYZE TABLE t1 PERSISTENT FOR ALL;
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
EXPLAIN EXTENDED SELECT * from t1 WHERE a between 1 and 5 and b <= 5;
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
EXPLAIN EXTENDED SELECT * from t1 WHERE a != 5;
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
EXPLAIN EXTENDED SELECT * from t1 WHERE b >= 10 and b < 25;
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
@ -631,7 +697,10 @@ drop table t1;
|
||||
CREATE TABLE t1( a INT, b INT, PRIMARY KEY( a ) );
|
||||
SELECT sum(b), row_number() OVER (order by b) FROM t1 WHERE a = 101;
|
||||
UPDATE t1 SET b=10 WHERE a=1;
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) AS JS from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
--enable_view_protocol
|
||||
DROP TABLE t1;
|
||||
|
||||
set optimizer_trace='enabled=off';
|
||||
@ -692,10 +761,13 @@ where
|
||||
c5 in (1,2,3,4,5,6,7,8,9,10) and
|
||||
c6 in (1,2,3,4);
|
||||
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select
|
||||
json_detailed(json_extract(trace, '$**.setup_range_conditions'))
|
||||
from
|
||||
information_schema.optimizer_trace;
|
||||
--enable_view_protocol
|
||||
|
||||
drop table t1;
|
||||
|
||||
@ -709,7 +781,9 @@ CREATE TABLE t (a int, b int);
|
||||
CREATE VIEW v AS SELECT 1 AS c UNION SELECT 2 AS c;
|
||||
INSERT INTO t VALUES (0,4),(5,6);
|
||||
UPDATE t, v SET t.b = t.a, t.a = v.c WHERE v.c < t.a;
|
||||
--disable_view_protocol
|
||||
SELECT * FROM information_schema.optimizer_trace;
|
||||
--enable_view_protocol
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
@ -802,11 +876,14 @@ set optimizer_trace=DEFAULT;
|
||||
--echo # MDEV-29179 Condition pushdown from HAVING into WHERE is not shown in optimizer trace
|
||||
--echo #
|
||||
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
CREATE TABLE t1 (a INT, b VARCHAR(1), KEY (a), KEY(b,a)) ENGINE=MEMORY;
|
||||
INSERT INTO t1 VALUES (4,'n'),(1,'h'),(NULL,'w');
|
||||
SET optimizer_trace= 'enabled=on';
|
||||
SELECT b, a FROM t1 WHERE b <> 'p' OR a = 4 GROUP BY b, a HAVING a <= 7; SELECT json_detailed(json_extract(trace, '$**.steps[*].join_optimization.steps[*].condition_pushdown_from_having') ) exp1, JSON_VALID(trace) exp2 FROM information_schema.optimizer_trace;
|
||||
DROP TABLE t1;
|
||||
--enable_view_protocol
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.4 tests
|
||||
@ -841,11 +918,11 @@ insert into t3 select a,a from t0;
|
||||
explain
|
||||
select * from t1 left join (t2 join t3 on t3.pk=1000) on t2.a=t1.a and t2.pk is null;
|
||||
|
||||
#enable after fix MDEV-27871
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.mark_join_nest_as_const'))
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.mark_join_nest_as_const')) as jd
|
||||
from information_schema.optimizer_trace;
|
||||
--enable_view_protocol
|
||||
--disable_view_protocol
|
||||
|
||||
drop table t0, t1, t2, t3;
|
||||
|
||||
@ -853,8 +930,6 @@ drop table t0, t1, t2, t3;
|
||||
--echo # MDEV-23767: IN-to-subquery conversion is not visible in optimizer trace
|
||||
--echo #
|
||||
|
||||
#enable after fix MDEV-27871
|
||||
--disable_view_protocol
|
||||
create table t0 (a int);
|
||||
INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
||||
@ -863,21 +938,30 @@ set in_predicate_conversion_threshold=3;
|
||||
|
||||
explain select * from t0 where a in (1,2,3,4,5,6);
|
||||
|
||||
select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion'))
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) as jd
|
||||
from information_schema.optimizer_trace;
|
||||
--enable_view_protocol
|
||||
|
||||
explain select * from t0 where a in (1,2,3,4,5,a+1);
|
||||
|
||||
select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion'))
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) as jd
|
||||
from information_schema.optimizer_trace;
|
||||
--enable_view_protocol
|
||||
|
||||
explain select * from t0 where a in ('1','2','3','4','5','6');
|
||||
select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion'))
|
||||
|
||||
#Enable after fix MDEV-32034
|
||||
--disable_view_protocol
|
||||
select json_detailed(json_extract(trace, '$**.in_to_subquery_conversion')) as jd
|
||||
from information_schema.optimizer_trace;
|
||||
--enable_view_protocol
|
||||
|
||||
set in_predicate_conversion_threshold=@tmp;
|
||||
drop table t0;
|
||||
--enable_view_protocol
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-29298: INSERT ... SELECT Does not produce an optimizer trace
|
||||
@ -889,7 +973,9 @@ set optimizer_trace=1;
|
||||
|
||||
insert into t2 select * from t1 where a<= b and a>4;
|
||||
|
||||
--disable_view_protocol
|
||||
select QUERY, LENGTH(trace)>1 from information_schema.optimizer_trace;
|
||||
--enable_view_protocol
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
|
Reference in New Issue
Block a user