Skip to content

Commit

Permalink
Merge branch '10.9' into 10.10
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed May 4, 2023
2 parents 13a294a + d7fae79 commit 16e5bc4
Show file tree
Hide file tree
Showing 17 changed files with 1,636 additions and 355 deletions.
537 changes: 537 additions & 0 deletions mysql-test/main/derived_split_innodb.result

Large diffs are not rendered by default.

212 changes: 212 additions & 0 deletions mysql-test/main/derived_split_innodb.test
Expand Up @@ -233,4 +233,216 @@ drop table t3, t4;

--echo # End of 10.3 tests


--echo #
--echo # MDEV-26301: Split optimization refills temporary table too many times
--echo #

# 5 values
create table t1(a int, b int);
insert into t1 select seq,seq from seq_1_to_5;

# 5 value groups of size 2 each
create table t2(a int, b int, key(a));
insert into t2
select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B;

# 5 value groups of size 3 each
create table t3(a int, b int, key(a));
insert into t3
select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B;

analyze table t1,t2,t3 persistent for all;

explain
select * from
(t1 left join t2 on t2.a=t1.b) left join t3 on t3.a=t1.b;

# Now, create tables for Groups.

create table t10 (
grp_id int,
col1 int,
key(grp_id)
);

# 100 groups of 100 values each
insert into t10
select
A.seq,
B.seq
from
seq_1_to_100 A,
seq_1_to_100 B;

# and X10 multiplier

create table t11 (
col1 int,
col2 int
);
insert into t11
select A.seq, A.seq from seq_1_to_10 A;

analyze table t10,t11 persistent for all;

let $q1=
select * from
(
(t1 left join t2 on t2.a=t1.b)
left join t3 on t3.a=t1.b
) left join (select grp_id, count(*)
from t10 left join t11 on t11.col1=t10.col1
group by grp_id) T on T.grp_id=t1.b;

eval
explain $q1;

--echo # The important part in the below output is:
--echo # "lateral": 1,
--echo # "query_block": {
--echo # "select_id": 2,
--echo # "r_loops": 5, <-- must be 5, not 30.
--source include/analyze-format.inc

eval
analyze format=json $q1;

create table t21 (pk int primary key);
insert into t21 values (1),(2),(3);

create table t22 (pk int primary key);
insert into t22 values (1),(2),(3);

# Same as above but throw in a couple of const tables.
explain
select * from
t21, t22,
(
(t1 left join t2 on t2.a=t1.b)
left join t3 on t3.a=t1.b
) left join (select grp_id, count(*)
from t10 left join t11 on t11.col1=t10.col1
group by grp_id) T on T.grp_id=t1.b
where
t21.pk=1 and t22.pk=2;

explain
select * from
t21,
(
(t1 left join t2 on t2.a=t1.b)
left join t3 on t3.a=t1.b
) left join (select grp_id, count(*)
from
t22 join t10 left join t11 on t11.col1=t10.col1
where
t22.pk=1
group by grp_id) T on T.grp_id=t1.b
where
t21.pk=1;

# And also add a non-const table

create table t5 (
pk int primary key
);
insert into t5 select seq from seq_1_to_1000;

explain
select * from
t21,
(
(((t1 join t5 on t5.pk=t1.b)) left join t2 on t2.a=t1.b)
left join t3 on t3.a=t1.b
) left join (select grp_id, count(*)
from
t22 join t10 left join t11 on t11.col1=t10.col1
where
t22.pk=1
group by grp_id) T on T.grp_id=t1.b
where
t21.pk=1;

drop table t1,t2,t3,t5, t10, t11, t21, t22;

# 5 values
create table t1(a int, b int);
insert into t1 select seq,seq from seq_1_to_5;

# 5 value groups of size 2 each
create table t2(a int, b int, key(a));
insert into t2
select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B;

# 5 value groups of size 3 each
create table t3(a int, b int, key(a));
insert into t3
select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B;

analyze table t1,t2,t3 persistent for all;

create table t10 (
grp_id int,
col1 int,
key(grp_id)
);

# 100 groups of 100 values each
insert into t10
select
A.seq,
B.seq
from
seq_1_to_100 A,
seq_1_to_100 B;

# and X10 multiplier

create table t11 (
col1 int,
col2 int
);
insert into t11
select A.seq, A.seq from seq_1_to_10 A;

analyze table t10,t11 persistent for all;

let $q=
select *
from
(
(t1 left join t2 on t2.a=t1.b)
left join
t3
on t3.a=t1.b
)
left join
(
select grp_id, count(*)
from t10 left join t11 on t11.col1=t10.col1
group by grp_id
)dt
on dt.grp_id=t1.b;

eval explain $q;
eval $q;

set join_cache_level=4;
eval explain $q;
eval $q;

set join_cache_level=default;

drop index a on t2;
drop index a on t3;

eval explain $q;
eval $q;

drop table t1,t2,t3;
drop table t10, t11;

--echo # End of 10.4 tests

SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;
18 changes: 18 additions & 0 deletions mysql-test/main/explain_innodb.result
Expand Up @@ -18,3 +18,21 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DERIVED t1 range NULL id 53 NULL 2 Using index for group-by
SET GLOBAL slow_query_log = @sql_tmp;
drop table t1;
#
# MDEV-31181: Server crash in subselect_uniquesubquery_engine::print
# upon EXPLAIN EXTENDED DELETE
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (pk INT PRIMARY KEY);
INSERT INTO t2 VALUES (1),(2);
EXPLAIN EXTENDED DELETE FROM t1 WHERE a IN (SELECT pk FROM t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
2 DEPENDENT SUBQUERY t2 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings:
Note 1003 /* select#1 */ delete from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`a`))))
drop table t1, t2;
#
# End of 10.4 tests
#
19 changes: 19 additions & 0 deletions mysql-test/main/explain_innodb.test
Expand Up @@ -18,3 +18,22 @@ SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt WHERE 1=0;

SET GLOBAL slow_query_log = @sql_tmp;
drop table t1;


--echo #
--echo # MDEV-31181: Server crash in subselect_uniquesubquery_engine::print
--echo # upon EXPLAIN EXTENDED DELETE
--echo #

CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (pk INT PRIMARY KEY);
INSERT INTO t2 VALUES (1),(2);

EXPLAIN EXTENDED DELETE FROM t1 WHERE a IN (SELECT pk FROM t2);

drop table t1, t2;

--echo #
--echo # End of 10.4 tests
--echo #

0 comments on commit 16e5bc4

Please sign in to comment.