Skip to content

Commit de5f734

Browse files
committed
Make main.subselect_sj2* tests stable
Use EITS statistics to avoid changing query plans
1 parent b1e3779 commit de5f734

File tree

4 files changed

+75
-24
lines changed

4 files changed

+75
-24
lines changed

mysql-test/main/subselect_sj2.result

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,14 @@ CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) E
813813
INSERT INTO t2 VALUES (6,'y');
814814
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
815815
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
816+
analyze table t1,t2,t3 persistent for all;
817+
Table Op Msg_type Msg_text
818+
test.t1 analyze status Engine-independent statistics collected
819+
test.t1 analyze status OK
820+
test.t2 analyze status Engine-independent statistics collected
821+
test.t2 analyze status OK
822+
test.t3 analyze status Engine-independent statistics collected
823+
test.t3 analyze status OK
816824
# The following must use LooseScan but not join buffering
817825
explain
818826
SELECT * FROM t3
@@ -1102,6 +1110,14 @@ INSERT INTO t2 VALUES
11021110
(9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
11031111
(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
11041112
(17,'q','q'),(18,'w','w'),(19,'d','d');
1113+
analyze table t1 persistent for all;
1114+
Table Op Msg_type Msg_text
1115+
test.t1 analyze status Engine-independent statistics collected
1116+
test.t1 analyze status OK
1117+
analyze table t2 persistent for all;
1118+
Table Op Msg_type Msg_text
1119+
test.t2 analyze status Engine-independent statistics collected
1120+
test.t2 analyze status OK
11051121
EXPLAIN
11061122
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
11071123
WHERE alias3.d IN (
@@ -1110,11 +1126,11 @@ WHERE alias5.b = alias4.b
11101126
AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
11111127
);
11121128
id select_type table type possible_keys key key_len ref rows Extra
1113-
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
1114-
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index
1115-
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3)
1116-
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
1129+
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
1130+
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
1131+
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
11171132
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
1133+
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
11181134
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
11191135
WHERE alias3.d IN (
11201136
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
@@ -1131,11 +1147,11 @@ WHERE alias5.b = alias4.b
11311147
AND ( alias5.b >= alias3.b OR alias3.c != alias5.c )
11321148
);
11331149
id select_type table type possible_keys key key_len ref rows Extra
1134-
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
1135-
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index
1136-
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3)
1137-
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
1150+
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
1151+
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
1152+
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
11381153
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
1154+
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
11391155
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
11401156
WHERE alias3.d IN (
11411157
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5

mysql-test/main/subselect_sj2.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ INSERT INTO t2 VALUES (6,'y');
994994
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
995995
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
996996

997+
analyze table t1,t2,t3 persistent for all;
997998
--echo # The following must use LooseScan but not join buffering
998999

9991000
--replace_column 9 #
@@ -1225,6 +1226,8 @@ INSERT INTO t2 VALUES
12251226
(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
12261227
(17,'q','q'),(18,'w','w'),(19,'d','d');
12271228

1229+
analyze table t1 persistent for all;
1230+
analyze table t2 persistent for all;
12281231
--replace_column 9 #
12291232
EXPLAIN
12301233
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3

mysql-test/main/subselect_sj2_jcl6.result

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,14 @@ CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) E
826826
INSERT INTO t2 VALUES (6,'y');
827827
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
828828
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
829+
analyze table t1,t2,t3 persistent for all;
830+
Table Op Msg_type Msg_text
831+
test.t1 analyze status Engine-independent statistics collected
832+
test.t1 analyze status OK
833+
test.t2 analyze status Engine-independent statistics collected
834+
test.t2 analyze status OK
835+
test.t3 analyze status Engine-independent statistics collected
836+
test.t3 analyze status OK
829837
# The following must use LooseScan but not join buffering
830838
explain
831839
SELECT * FROM t3
@@ -1115,6 +1123,14 @@ INSERT INTO t2 VALUES
11151123
(9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
11161124
(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
11171125
(17,'q','q'),(18,'w','w'),(19,'d','d');
1126+
analyze table t1 persistent for all;
1127+
Table Op Msg_type Msg_text
1128+
test.t1 analyze status Engine-independent statistics collected
1129+
test.t1 analyze status OK
1130+
analyze table t2 persistent for all;
1131+
Table Op Msg_type Msg_text
1132+
test.t2 analyze status Engine-independent statistics collected
1133+
test.t2 analyze status OK
11181134
EXPLAIN
11191135
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
11201136
WHERE alias3.d IN (
@@ -1123,11 +1139,11 @@ WHERE alias5.b = alias4.b
11231139
AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
11241140
);
11251141
id select_type table type possible_keys key key_len ref rows Extra
1126-
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
1127-
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index; Using join buffer (flat, BNL join)
1128-
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3); Using join buffer (incremental, BKA join); Key-ordered scan
1142+
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
1143+
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
1144+
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
1145+
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
11291146
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join)
1130-
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join)
11311147
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
11321148
WHERE alias3.d IN (
11331149
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
@@ -1144,11 +1160,11 @@ WHERE alias5.b = alias4.b
11441160
AND ( alias5.b >= alias3.b OR alias3.c != alias5.c )
11451161
);
11461162
id select_type table type possible_keys key key_len ref rows Extra
1147-
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
1148-
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index; Using join buffer (flat, BNL join)
1149-
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3); Using join buffer (incremental, BKA join); Key-ordered scan
1163+
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
1164+
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
1165+
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
1166+
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
11501167
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join)
1151-
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join)
11521168
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
11531169
WHERE alias3.d IN (
11541170
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5

mysql-test/main/subselect_sj2_mat.result

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,14 @@ CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) E
815815
INSERT INTO t2 VALUES (6,'y');
816816
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
817817
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
818+
analyze table t1,t2,t3 persistent for all;
819+
Table Op Msg_type Msg_text
820+
test.t1 analyze status Engine-independent statistics collected
821+
test.t1 analyze status OK
822+
test.t2 analyze status Engine-independent statistics collected
823+
test.t2 analyze status OK
824+
test.t3 analyze status Engine-independent statistics collected
825+
test.t3 analyze status OK
818826
# The following must use LooseScan but not join buffering
819827
explain
820828
SELECT * FROM t3
@@ -1104,6 +1112,14 @@ INSERT INTO t2 VALUES
11041112
(9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
11051113
(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
11061114
(17,'q','q'),(18,'w','w'),(19,'d','d');
1115+
analyze table t1 persistent for all;
1116+
Table Op Msg_type Msg_text
1117+
test.t1 analyze status Engine-independent statistics collected
1118+
test.t1 analyze status OK
1119+
analyze table t2 persistent for all;
1120+
Table Op Msg_type Msg_text
1121+
test.t2 analyze status Engine-independent statistics collected
1122+
test.t2 analyze status OK
11071123
EXPLAIN
11081124
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
11091125
WHERE alias3.d IN (
@@ -1112,11 +1128,11 @@ WHERE alias5.b = alias4.b
11121128
AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
11131129
);
11141130
id select_type table type possible_keys key key_len ref rows Extra
1115-
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
1116-
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index
1117-
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3)
1118-
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
1131+
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
1132+
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
1133+
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
11191134
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
1135+
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
11201136
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
11211137
WHERE alias3.d IN (
11221138
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
@@ -1133,11 +1149,11 @@ WHERE alias5.b = alias4.b
11331149
AND ( alias5.b >= alias3.b OR alias3.c != alias5.c )
11341150
);
11351151
id select_type table type possible_keys key key_len ref rows Extra
1136-
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
1137-
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index
1138-
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3)
1139-
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
1152+
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
1153+
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
1154+
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
11401155
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
1156+
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
11411157
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
11421158
WHERE alias3.d IN (
11431159
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5

0 commit comments

Comments
 (0)