diff options
Diffstat (limited to 'mysql-test/r/join_cache.result')
-rw-r--r-- | mysql-test/r/join_cache.result | 252 |
1 files changed, 214 insertions, 38 deletions
diff --git a/mysql-test/r/join_cache.result b/mysql-test/r/join_cache.result index 0e616e259bc..1ef17b0763e 100644 --- a/mysql-test/r/join_cache.result +++ b/mysql-test/r/join_cache.result @@ -3037,12 +3037,12 @@ t1.metaid = t2.metaid AND t1.affiliateid = '2'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 system PRIMARY NULL NULL NULL 1 1 SIMPLE t1 ref t1_affiliateid,t1_metaid t1_affiliateid 4 const 1 -1 SIMPLE t4 ref PRIMARY,t4_formatclassid,t4_formats_idx t4_formats_idx 1 const 1 Using index condition; Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t5 eq_ref PRIMARY,t5_formattypeid PRIMARY 4 test.t4.formatclassid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t7 ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using index -1 SIMPLE t3 ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaid 4 test.t1.metaid 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t8 eq_ref PRIMARY PRIMARY 4 test.t7.artistid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t8 eq_ref PRIMARY PRIMARY 4 test.t7.artistid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaidformatid 4 test.t1.metaid 1 Using index condition; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t4 eq_ref PRIMARY,t4_formatclassid,t4_formats_idx PRIMARY 4 test.t3.formatid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t5 eq_ref PRIMARY,t5_formattypeid PRIMARY 4 test.t4.formatclassid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t9 index PRIMARY,t9_subgenreid,t9_metaid PRIMARY 8 NULL 2 Using where; Using index; Using join buffer (incremental, BNL join) 1 SIMPLE t10 eq_ref PRIMARY,t10_genreid PRIMARY 4 test.t9.subgenreid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t10.genreid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan @@ -3151,6 +3151,8 @@ CREATE TABLE t2 (a int, b int, INDEX idx(a)); INSERT INTO t1 VALUES (5,30), (3,20), (7,40), (2,10), (8,30), (1,10), (4,20); INSERT INTO t2 VALUES (7,10), (1,20), (2,20), (8,20), (8,10), (1,20); INSERT INTO t2 VALUES (1,10), (4,20), (3,20), (7,20), (7,10), (1,20); +INSERT INTO t2 VALUES (17,10), (11,20), (12,20), (18,20), (18,10), (11,20); +INSERT INTO t2 VALUES (11,10), (14,20), (13,20), (17,20), (17,10), (11,20); set join_buffer_size=32; Warnings: Warning 1292 Truncated incorrect join_buffer_size value: '32' @@ -3176,6 +3178,7 @@ CREATE TABLE t1 (a int NOT NULL); INSERT INTO t1 VALUES (2), (4), (3), (5), (1); CREATE TABLE t2 (a int NOT NULL, b int NOT NULL, INDEX i_a(a)); INSERT INTO t2 VALUES (4,10), (2,10), (2,30), (2,20), (4,20); +INSERT INTO t2 VALUES (14,10), (12,10), (15,30), (12,20), (14,20); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; id select_type table type possible_keys key key_len ref rows Extra @@ -3566,6 +3569,9 @@ create table t2 (id1 int, id2 int, index idx2 (id1)); insert into t2 values (20, 100), (30, 400), (20, 400), (30, 200), (10, 300), (10, 200), (40, 100), (40, 200), (30, 300), (10, 400), (20, 200), (20, 300); +insert into t2 values +(21, 10), (31, 400), (21, 400), (31, 200), (11, 300), (11, 200), (41, 100), +(41, 200), (31, 300), (11, 400), (21, 200), (21, 300); set join_cache_level=6; explain select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 @@ -3613,14 +3619,26 @@ insert into t2 values (30, 'bbb'), (10, 'b'), (70, 'bbbbbbb'), (60, 'bbbbbb'), (31, 'bbb'), (11, 'b'), (71, 'bbbbbbb'), (61, 'bbbbbb'), (32, 'bbb'), (12, 'b'), (72, 'bbbbbbb'), (62, 'bbbbbb'); +insert into t2 values +(130, 'bbb'), (110, 'b'), (170, 'bbbbbbb'), (160, 'bbbbbb'), +(131, 'bbb'), (111, 'b'), (171, 'bbbbbbb'), (161, 'bbbbbb'), +(132, 'bbb'), (112, 'b'), (172, 'bbbbbbb'), (162, 'bbbbbb'); insert into t3 values (4000, 'dddd'), (3000, 'ddd'), (1000, 'd'), (8000, 'dddddddd'), (4001, 'dddd'), (3001, 'ddd'), (1001, 'd'), (8001, 'dddddddd'), (4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); +insert into t3 values +(14000, 'dddd'), (13000, 'ddd'), (11000, 'd'), (18000, 'dddddddd'), +(14001, 'dddd'), (13001, 'ddd'), (11001, 'd'), (18001, 'dddddddd'), +(4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); insert into t4 values (200, 'cc'), (600, 'cccccc'), (300, 'ccc'), (500, 'ccccc'), (201, 'cc'), (601, 'cccccc'), (301, 'ccc'), (501, 'ccccc'), (202, 'cc'), (602, 'cccccc'), (302, 'ccc'), (502, 'ccccc'); +insert into t4 values +(1200, 'cc'), (1600, 'cccccc'), (1300, 'ccc'), (1500, 'ccccc'), +(1201, 'cc'), (1601, 'cccccc'), (1301, 'ccc'), (1501, 'ccccc'), +(1202, 'cc'), (1602, 'cccccc'), (1302, 'ccc'), (1502, 'ccccc'); analyze table t2,t3,t4; set join_cache_level=1; explain @@ -3968,7 +3986,9 @@ DROP TABLE t1,t2,t3,t4; CREATE TABLE t1 (b int); INSERT INTO t1 VALUES (NULL),(3); CREATE TABLE t2 (a int, b int, KEY (b)); -INSERT INTO t2 VALUES (100,NULL),(150,200); +INSERT INTO t2 VALUES +(100,NULL),(150,200),(50,150),(250,350),(180,210),(100,150), +(101,NULL),(151,200),(51,150),(251,350),(181,210),(101,150); set join_cache_level = 5; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; id select_type table type possible_keys key key_len ref rows Extra @@ -4003,6 +4023,7 @@ CREATE TABLE t1 (b varchar(100)); INSERT INTO t1 VALUES (NULL),("some varchar"); CREATE TABLE t2 (a int, b varchar(100), KEY (b)); INSERT INTO t2 VALUES (100,NULL),(150,"varchar"),(200,NULL),(250,"long long varchar"); +INSERT INTO t2 VALUES (100,NULL),(150,"long varchar"),(200,"varchar"),(250,"long long long varchar"); set join_cache_level = 5; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; id select_type table type possible_keys key key_len ref rows Extra @@ -4117,6 +4138,17 @@ INSERT INTO t3 VALUES (1,0,'2002-07-13','06:34:26','v','v'), (9,3,'2003-01-03','18:07:38','m','m'), (1,5,'2006-04-02','13:55:23','z','z'), (3,9,'2006-10-19','20:32:28','n','n'), (8,1,'2005-06-08','11:57:44','d','d'), (231,107,'2006-12-26','03:10:35','a','a'); +INSERT INTO t3 VALUES +(103,108,'2008-12-04','00:00:00','a','v'), (103,108,'2009-03-28','00:00:00','b','f'), +(103,105,'1900-01-01','00:55:47','c','v'), (102,108,'2009-10-02','00:00:00','d','s'), +(100,108,'1900-01-01','20:51:59','e','a'), (100,106,'2008-06-04','09:47:27','f','p'), +(108,107,'2009-01-13','21:58:29','g','z'), (105,102,'1900-01-01','22:45:53','h','a'), +(109,105,'2008-01-28','14:06:48','i','h'), (105,107,'2004-09-18','22:17:16','j','h'), +(104,102,'2006-10-14','14:59:37','k','v'), (102,109,'1900-01-01','23:37:40','l','v'), +(1033,1142,'2000-11-28','14:14:01','m','b'), (105,103,'2008-04-04','02:54:19','n','y'), +(100,100,'2002-07-13','06:34:26','o','v'), (109,103,'2003-01-03','18:07:38','p','m'), +(100,105,'2006-04-02','13:55:23','q','z'), (103,109,'2006-10-19','20:32:28','s','n'), +(108,100,'2005-06-08','11:57:44','t','d'), (1231,1107,'2006-12-26','03:10:35','v','a'); CREATE TABLE t1 SELECT * FROM t3; DELETE FROM t1 WHERE i > 8; CREATE TABLE t2 SELECT * FROM t3; @@ -4127,55 +4159,87 @@ WHERE t3.u <='a' AND t2.j < 5 AND t3.v = t2.u; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 16 1 SIMPLE t2 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t3 hash_ALL idx #hash#idx 3 test.t2.u 20 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 hash_ALL idx #hash#idx 3 test.t2.u 40 Using where; Using join buffer (flat, BNLH join) SELECT t1.i, t1.d, t1.v, t2.i, t2.d, t2.t, t2.v FROM t1,t2,t3 WHERE t3.u <='a' AND t2.j < 5 AND t3.v = t2.u; i d v i d t v +0 2008-06-04 p 1 2002-07-13 06:34:26 v +0 2008-06-04 p 4 2006-10-14 14:59:37 v 0 2008-06-04 p 5 1900-01-01 22:45:53 a 0 2008-06-04 p 5 1900-01-01 22:45:53 a 0 2008-06-04 p 5 1900-01-01 22:45:53 a +1 1900-01-01 a 1 2002-07-13 06:34:26 v +1 1900-01-01 a 4 2006-10-14 14:59:37 v 1 1900-01-01 a 5 1900-01-01 22:45:53 a 1 1900-01-01 a 5 1900-01-01 22:45:53 a 1 1900-01-01 a 5 1900-01-01 22:45:53 a +1 2002-07-13 v 1 2002-07-13 06:34:26 v +1 2002-07-13 v 4 2006-10-14 14:59:37 v 1 2002-07-13 v 5 1900-01-01 22:45:53 a 1 2002-07-13 v 5 1900-01-01 22:45:53 a 1 2002-07-13 v 5 1900-01-01 22:45:53 a +1 2006-04-02 z 1 2002-07-13 06:34:26 v +1 2006-04-02 z 4 2006-10-14 14:59:37 v 1 2006-04-02 z 5 1900-01-01 22:45:53 a 1 2006-04-02 z 5 1900-01-01 22:45:53 a 1 2006-04-02 z 5 1900-01-01 22:45:53 a +2 1900-01-01 v 1 2002-07-13 06:34:26 v +2 1900-01-01 v 4 2006-10-14 14:59:37 v 2 1900-01-01 v 5 1900-01-01 22:45:53 a 2 1900-01-01 v 5 1900-01-01 22:45:53 a 2 1900-01-01 v 5 1900-01-01 22:45:53 a +2 2009-10-02 s 1 2002-07-13 06:34:26 v +2 2009-10-02 s 4 2006-10-14 14:59:37 v 2 2009-10-02 s 5 1900-01-01 22:45:53 a 2 2009-10-02 s 5 1900-01-01 22:45:53 a 2 2009-10-02 s 5 1900-01-01 22:45:53 a +3 1900-01-01 v 1 2002-07-13 06:34:26 v +3 1900-01-01 v 4 2006-10-14 14:59:37 v 3 1900-01-01 v 5 1900-01-01 22:45:53 a 3 1900-01-01 v 5 1900-01-01 22:45:53 a 3 1900-01-01 v 5 1900-01-01 22:45:53 a +3 2006-10-19 n 1 2002-07-13 06:34:26 v +3 2006-10-19 n 4 2006-10-14 14:59:37 v 3 2006-10-19 n 5 1900-01-01 22:45:53 a 3 2006-10-19 n 5 1900-01-01 22:45:53 a 3 2006-10-19 n 5 1900-01-01 22:45:53 a +3 2008-12-04 v 1 2002-07-13 06:34:26 v +3 2008-12-04 v 4 2006-10-14 14:59:37 v 3 2008-12-04 v 5 1900-01-01 22:45:53 a 3 2008-12-04 v 5 1900-01-01 22:45:53 a 3 2008-12-04 v 5 1900-01-01 22:45:53 a +3 2009-03-28 f 1 2002-07-13 06:34:26 v +3 2009-03-28 f 4 2006-10-14 14:59:37 v 3 2009-03-28 f 5 1900-01-01 22:45:53 a 3 2009-03-28 f 5 1900-01-01 22:45:53 a 3 2009-03-28 f 5 1900-01-01 22:45:53 a +4 2006-10-14 v 1 2002-07-13 06:34:26 v +4 2006-10-14 v 4 2006-10-14 14:59:37 v 4 2006-10-14 v 5 1900-01-01 22:45:53 a 4 2006-10-14 v 5 1900-01-01 22:45:53 a 4 2006-10-14 v 5 1900-01-01 22:45:53 a +5 1900-01-01 a 1 2002-07-13 06:34:26 v +5 1900-01-01 a 4 2006-10-14 14:59:37 v 5 1900-01-01 a 5 1900-01-01 22:45:53 a 5 1900-01-01 a 5 1900-01-01 22:45:53 a 5 1900-01-01 a 5 1900-01-01 22:45:53 a +5 2004-09-18 h 1 2002-07-13 06:34:26 v +5 2004-09-18 h 4 2006-10-14 14:59:37 v 5 2004-09-18 h 5 1900-01-01 22:45:53 a 5 2004-09-18 h 5 1900-01-01 22:45:53 a 5 2004-09-18 h 5 1900-01-01 22:45:53 a +5 2008-04-04 y 1 2002-07-13 06:34:26 v +5 2008-04-04 y 4 2006-10-14 14:59:37 v 5 2008-04-04 y 5 1900-01-01 22:45:53 a 5 2008-04-04 y 5 1900-01-01 22:45:53 a 5 2008-04-04 y 5 1900-01-01 22:45:53 a +8 2005-06-08 d 1 2002-07-13 06:34:26 v +8 2005-06-08 d 4 2006-10-14 14:59:37 v 8 2005-06-08 d 5 1900-01-01 22:45:53 a 8 2005-06-08 d 5 1900-01-01 22:45:53 a 8 2005-06-08 d 5 1900-01-01 22:45:53 a +8 2009-01-13 z 1 2002-07-13 06:34:26 v +8 2009-01-13 z 4 2006-10-14 14:59:37 v 8 2009-01-13 z 5 1900-01-01 22:45:53 a 8 2009-01-13 z 5 1900-01-01 22:45:53 a 8 2009-01-13 z 5 1900-01-01 22:45:53 a @@ -4193,7 +4257,15 @@ PRIMARY KEY (pk), INDEX idx1(i), INDEX idx2 (v,i) INSERT INTO t1 VALUES (10,8,'v'), (11,8,'f'), (12,5,'v'), (13,8,'s'), (14,8,'a'), (15,6,'p'), (16,7,'z'), (17,2,'a'), (18,5,'h'), (19,7,'h'), -(25,3,'m'), (26,5,'z'), (27,9,'n'), (28,1,'d'), (29,107,'a'); +(25,3,'m'), (26,5,'a'), (27,9,'n'), (28,1,'d'), (29,107,'a'); +INSERT INTO t1 VALUES +(110,8,'x'), (111,8,'y'), (112,5,'v'), (113,8,'z'), (114,8,'i'), +(115,6,'j'), (116,7,'t'), (117,2,'b'), (118,5,'j'), (119,7,'w'), +(125,3,'q'), (126,5,'o'), (127,9,'n'), (128,1,'e'), (129,107,'c'); +INSERT INTO t1 VALUES +(210,8,'b'), (211,8,'c'), (212,5,'d'), (213,8,'e'), (214,8,'g'), +(215,6,'f'), (216,7,'h'), (217,2,'i'), (218,5,'j'), (219,7,'k'), +(225,3,'l'), (226,5,'m'), (227,9,'n'), (228,1,'o'), (229,107,'p'); CREATE TABLE t2 ( pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL, PRIMARY KEY (pk), INDEX idx1(i), INDEX idx2(v,i) @@ -4202,7 +4274,7 @@ INSERT INTO t2 VALUES (10,8,'v'), (11,8,'f'), (12,5,'v'), (13,8,'s'), (14,8,'a'), (15,6,'p'), (16,7,'z'), (17,2,'a'), (18,5,'h'), (19,7,'h'), (20,2,'v'), (21,9,'v'), (22,142,'b'), (23,3,'y'), (24,0,'v'), -(25,3,'m'), (26,5,'z'), (27,9,'n'), (28,1,'d'), (29,107,'a'); +(25,3,'m'), (26,5,'b'), (27,9,'n'), (28,1,'d'), (29,107,'a'); CREATE TABLE t3 ( pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL, PRIMARY KEY (pk), INDEX idx1(i), INDEX idx2(v,i) @@ -4214,49 +4286,55 @@ INSERT INTO t3 VALUES (16,6,'e'), (17,3,'t'), (18,8,'j'), (19,5,'h'), (20,7,'w'); SET SESSION join_cache_level=1; EXPLAIN -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index idx1 idx2 7 NULL 20 Using index; Using temporary; Using filesort 1 SIMPLE t3 eq_ref PRIMARY,idx2 PRIMARY 4 test.t2.i 1 Using where -1 SIMPLE t1 ref idx2 idx2 3 test.t3.v 2 -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +1 SIMPLE t1 ref idx2 idx2 3 test.t3.v 5 Using where +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; v +b h -z -p n v +p SET SESSION join_cache_level=6; EXPLAIN -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL idx1 NULL NULL NULL 20 Using temporary; Using filesort 1 SIMPLE t3 eq_ref PRIMARY,idx2 PRIMARY 4 test.t2.i 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t1 ref idx2 idx2 3 test.t3.v 2 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +1 SIMPLE t1 ref idx2 idx2 3 test.t3.v 5 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; v +b h -z n v p SET SESSION join_cache_level=4; EXPLAIN -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL idx1 NULL NULL NULL 20 Using temporary; Using filesort 1 SIMPLE t3 hash_ALL PRIMARY,idx2 #hash#PRIMARY 4 test.t2.i 20 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE t1 hash_ALL idx2 #hash#idx2 3 test.t3.v 15 Using join buffer (incremental, BNLH join) -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +1 SIMPLE t1 hash_ALL idx2 #hash#idx2 3 test.t3.v 45 Using where; Using join buffer (incremental, BNLH join) +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; v +b h -z n v p @@ -4323,13 +4401,18 @@ INSERT INTO t2 VALUES (1, 12, 102), (8, 81, 801), (7, 70, 700), (12, 120, 1200), (8, 82, 802), (1, 13, 103), (1, 14, 104), (3, 31, 301), (1, 15, 105), (8, 83, 803), (7, 71, 701); +INSERT INTO t2 VALUES +(108, 80, 800), (101, 10, 100), (101, 11, 101), (103, 30, 300), +(101, 12, 102), (108, 81, 801), (107, 70, 700), (1012, 120, 1200), +(108, 82, 802), (101, 13, 103), (101, 14, 104), (103, 31, 301), +(101, 15, 105), (108, 83, 803), (107, 71, 701); SET SESSION join_cache_level = 4; SET SESSION join_buffer_size = 256; EXPLAIN SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 36 Using where -1 SIMPLE t2 hash_ALL idx #hash#idx 10 test.t1.a,const 15 Using join buffer (flat, BNLH join) +1 SIMPLE t1 ALL NULL NULL NULL NULL 36 +1 SIMPLE t2 ALL idx NULL NULL NULL 30 Using where; Using join buffer (flat, BNL join) SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99; a c SET SESSION join_cache_level = DEFAULT; @@ -4356,20 +4439,27 @@ INSERT INTO t2 VALUES ('abcdefjhjk',1015414784), ('or',4), ('now',0), ('abcdefjhjk',-32702464), ('abcdefjhjk',4), ('time',1078394880), ('f',4), ('m',-1845559296), ('ff', 5), ('abcdefjhjk',-1074397184); +INSERT INTO t2 VALUES +('dig',5), ('were',-1631322112), ('is',3), ('abcdefjhjl',3), +('abcdefjh',4), ('told',-824573952), ('tt',0),('vv',-1711013888), +('abcdefjhjj',1015414784), ('and',4), ('here',0), ('abcdefjhjm',-32702464), +('abcdefjhji',4), ('space',1078394880), ('fs',4), ('mn',-1845559296), +('fq', 5), ('abcdefjhjp',-1074397184); EXPLAIN SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where -1 SIMPLE t2 ref idx idx 13 test.t1.v 2 +1 SIMPLE t2 ref idx idx 13 test.t1.v 3 SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v; v i +abcdefjh 4 f 4 f 4 EXPLAIN SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 -1 SIMPLE t2 ref idx idx 13 func 2 Using index condition +1 SIMPLE t2 ref idx idx 13 func 3 Using index condition SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); v i f 5 @@ -4379,16 +4469,17 @@ EXPLAIN SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where -1 SIMPLE t2 hash_ALL idx #hash#idx 13 test.t1.v 18 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 13 test.t1.v 36 Using join buffer (flat, BNLH join) SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v; v i f 4 f 4 +abcdefjh 4 EXPLAIN SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 -1 SIMPLE t2 hash_ALL idx #hash#idx 13 func 18 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 13 func 36 Using where; Using join buffer (flat, BNLH join) SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); v i f 5 @@ -4419,6 +4510,13 @@ INSERT INTO t2 VALUES (11,6,'yes'), (12,NULL,'will'), (13,NULL,'o'), (14,NULL,'k'), (15,NULL,'she'), (16,-1450835968,'abcdefjhjkl'), (17,-975831040,'abcdefjhjkl'), (18,NULL,'z'), (19,-343932928,'t'); +INSERT INTO t2 VALUES +(101,6,'yes'), (102,NULL,'will'), (103,NULL,'o'), (104,NULL,'k'), (105,NULL,'she'), +(106,-1450835968,'abcdefjhjkl'), (107,-975831040,'abcdefjhjkl'), (108,NULL,'z'), +(100,-343932928,'t'), +(111,6,'yes'), (112,NULL,'will'), (113,NULL,'o'), (114,NULL,'k'), (115,NULL,'she'), +(116,-1450835968,'abcdefjhjkl'), (117,-975831040,'abcdefjhjkl'), (118,NULL,'z'), +(119,-343932928,'t'); CREATE TABLE t3 ( pk int NOT NULL PRIMARY KEY, i int, @@ -4434,6 +4532,15 @@ INSERT INTO t3 VALUES (26,NULL,'all'), (27,1443168256,'c'), (28,1427046400,'right'), (31,7,'abcdefjhjkl'), (32,6,'y'), (33,NULL,'to'), (34,7,'n'), (35,7,'look'), (36,NULL,'all'), (37,1443168256,'c'), (38,1427046400,'right'); +INSERT INTO t3 VALUES +(101,7,'abcdefjhjkl'),(102,6,'y'), (103,NULL,'to'),(104,7,'n'),(105,7,'look'), +(106,NULL,'all'), (107,1443168256,'c'), (108,1427046400,'right'), +(111,7,'abcdefjhjkl'), (112,6,'y'), (113,NULL,'to'), (114,7,'n'), (115,7,'look'), +(116,NULL,'all'), (117,1443168256,'c'), (118,1427046400,'right'), +(121,7,'abcdefjhjkl'), (122,6,'y'), (123,NULL,'to'), (124,7,'n'), (125,7,'look'), +(126,NULL,'all'), (127,1443168256,'c'), (128,1427046400,'right'), +(131,7,'abcdefjhjkl'), (132,6,'y'), (133,NULL,'to'), (134,7,'n'), (135,7,'look'), +(136,NULL,'all'), (137,1443168256,'c'), (138,1427046400,'right'); SET SESSION join_buffer_size = 256; SET SESSION join_cache_level = 4; EXPLAIN @@ -4441,8 +4548,8 @@ SELECT t3.i FROM t1,t2,t3 WHERE t1.v = t2.v AND t3.v = t1.v AND t2.i <> 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index idx idx 13 NULL 7 Using where; Using index -1 SIMPLE t2 hash_ALL idx #hash#idx 1003 test.t1.v 18 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE t3 hash_ALL idx #hash#idx 1002 func 32 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 1003 test.t1.v 36 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 hash_ALL idx #hash#idx 1002 func 64 Using where; Using join buffer (incremental, BNLH join) SELECT t3.i FROM t1,t2,t3 WHERE t1.v = t2.v AND t3.v = t1.v AND t2.i <> 0; i @@ -4467,19 +4574,28 @@ INSERT INTO t2 VALUES (10, 'a'), (20, 'c'), (30, 'aa'), (4, 'bb'), (11, 'a'), (21, 'c'), (31, 'aa'), (41, 'cc'), (12, 'a'), (22, 'c'), (32, 'bb'), (42, 'aa'); +INSERT INTO t2 VALUES +(110, 'a'), (120, 'c'), (130, 'aa'), (14, 'bb'), +(111, 'a'), (121, 'c'), (131, 'aa'), (141, 'cc'), +(112, 'a'), (122, 'c'), (132, 'bb'), (142, 'aa'); SELECT * FROM t1,t2 WHERE t2.a=t1.a; pk a pk a 2 aa 30 aa 2 aa 31 aa 2 aa 42 aa +2 aa 130 aa +2 aa 131 aa +2 aa 142 aa 3 bb 4 bb 3 bb 32 bb +3 bb 14 bb +3 bb 132 bb SET SESSION join_cache_level = 4; EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL idx NULL NULL NULL 3 Using where -1 SIMPLE t2 hash_ALL idx #hash#idx 515 test.t1.a 12 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 515 test.t1.a 24 Using join buffer (flat, BNLH join) SELECT * FROM t1,t2 WHERE t2.a=t1.a; pk a pk a 2 aa 30 aa @@ -4487,6 +4603,11 @@ pk a pk a 2 aa 31 aa 3 bb 32 bb 2 aa 42 aa +2 aa 130 aa +3 bb 14 bb +2 aa 131 aa +3 bb 132 bb +2 aa 142 aa SET SESSION join_cache_level = DEFAULT; DROP TABLE t1,t2; # @@ -4569,6 +4690,9 @@ CREATE TABLE t3 (pk int, a3 int, c3 int, d3 int) ; INSERT IGNORE INTO t3 VALUES (9,0,0,2), (1,0,0,7); CREATE TABLE t4 (pk int, a4 int, INDEX idx(a4)) ; INSERT IGNORE INTO t4 VALUES (2,NULL), (8,0); +INSERT IGNORE INTO t4 VALUES (12,10), (18,20); +INSERT IGNORE INTO t4 VALUES (22,11), (28,21); +INSERT IGNORE INTO t4 VALUES (32,12), (38,22); CREATE TABLE t5 (pk int, a5 int) ; INSERT IGNORE INTO t5 VALUES (2,0), (8,0); SET SESSION optimizer_switch = 'outer_join_with_cache=on'; @@ -4786,13 +4910,16 @@ INSERT INTO t1 VALUES INSERT INTO t2 VALUES (1,'Bbbb'), (2,'BBB'), (3,'bbbb'), (4,'AaA'), (5,'CC'), (6,'cC'), (7,'CCC'), (8,'AAA'), (9,'bBbB'), (10,'aaaa'), -(11,'a'), (12,'dd'), (13,'EE'), (14,'ee'), (15,'D'); +(11,'a'), (12,'dd'), (13,'EE'), (14,'ee'), (15,'D'), +(101,'Bbbb'), (102,'BBB'), (103,'bbbb'), (104,'AaA'), (105,'CC'), +(106,'cC'), (107,'CCC'), (108,'AAA'), (109,'bBbB'), (110,'aaaa'), +(111,'a'), (112,'dd'), (113,'EE'), (114,'ee'), (115,'D'); SET SESSION join_cache_level = 4; EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where -1 SIMPLE t2 hash_ALL idx #hash#idx 35 test.t1.a 15 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 35 test.t1.a 30 Using join buffer (flat, BNLH join) SELECT * FROM t1,t2 WHERE t1.a=t2.a; pk a pk a 20 BBBB 1 Bbbb @@ -4805,6 +4932,16 @@ pk a pk a 40 DD 12 dd 50 ee 13 EE 50 ee 14 ee +20 BBBB 101 Bbbb +20 BBBB 103 bbbb +10 AAA 104 AaA +30 Cc 105 CC +30 Cc 106 cC +10 AAA 108 AAA +20 BBBB 109 bBbB +40 DD 112 dd +50 ee 113 EE +50 ee 114 ee SET SESSION join_cache_level = DEFAULT; DROP TABLE t1,t2; # @@ -4834,7 +4971,7 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Rowid-ordered scan +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan 1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); @@ -4929,13 +5066,15 @@ CREATE TABLE t2 ( f1 varchar(10) , f2 int(11) , KEY (f1)); INSERT INTO t2 VALUES ('hgtofubn',1), ('GDOXZ',91), ('n',2), ('fggxgalh',88), ('hgtofu',1), ('GDO',101), ('n',3), ('fggxga',55), -('hgtofu',3), ('GDO',33), ('nn',3), ('fggxgarrr',77); +('hgtofu',3), ('GDO',33), ('nn',3), ('fggxgarrr',77), +('jgtofu',3), ('JDO',33), ('mn',3), ('jggxgarrr',77), +('igtofu',3), ('IDO',33), ('ln',3), ('iggxgarrr',77); SET SESSION join_cache_level=3; EXPLAIN SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL f1 NULL NULL NULL 2 Using where -1 SIMPLE t2 hash_ALL f1 #hash#f1 13 test.t1.f1 12 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL f1 #hash#f1 13 test.t1.f1 20 Using join buffer (flat, BNLH join) SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1; f1 f2 f1 f2 SET SESSION join_cache_level = DEFAULT; @@ -4948,17 +5087,20 @@ INSERT INTO t1 VALUES ('o'), ('u'); CREATE TABLE t2 (a int, v varchar(1), INDEX idx (v)) ; INSERT INTO t2 VALUES (8,NULL), (10,'b'), (5,'k'), (4,NULL), -(1,NULL), (11,'u'), (7,NULL), (2,'d'); +(1,NULL), (11,'u'), (7,NULL), (2,'d'), +(18,'u'), (11,'b'), (15,'k'), (12,'d'), +(18,'x'), (11,'y'), (15,'l'), (12,'e'); SET SESSION join_buffer_size = 256; SET SESSION join_cache_level = 4; EXPLAIN SELECT a FROM t1,t2 WHERE t2.v = t1.v ; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where -1 SIMPLE t2 hash_ALL idx #hash#idx 4 test.t1.v 8 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 4 test.t1.v 16 Using join buffer (flat, BNLH join) SELECT a FROM t1,t2 WHERE t2.v = t1.v ; a 11 +18 SET SESSION join_cache_level = 1; EXPLAIN SELECT a FROM t1,t2 WHERE t2.v = t1.v ; @@ -4968,6 +5110,7 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT a FROM t1,t2 WHERE t2.v = t1.v ; a 11 +18 SET SESSION join_cache_level = DEFAULT; SET SESSION join_buffer_size = DEFAULT; DROP TABLE t1,t2; @@ -5006,4 +5149,37 @@ a 0 SET SESSION join_cache_level = DEFAULT; DROP TABLE t1, t2; +# +# Bug #887479: join_cache_level=3 + semijoin=on +# +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (3914,17), (3710,5), (3888,20); +CREATE TABLE t2 (c int, KEY (c)); +INSERT INTO t2 VALUES (27), (17), (33), (20), (3), (7), (18), (2); +SET @tmp887479_optimizer_switch=@@optimizer_switch; +SET SESSION optimizer_switch='semijoin=on'; +SET SESSION optimizer_switch='semijoin_with_cache=on'; +SET SESSION join_cache_level=1; +EXPLAIN +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t2 ref c c 5 test.t1.b 2 Using index; Start temporary; End temporary +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); +a b +3914 17 +3888 20 +SET SESSION join_cache_level=3; +EXPLAIN +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t2 hash_index c #hash#c:c 5:5 test.t1.b 8 End temporary; Using join buffer (flat, BNLH join) +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); +a b +3914 17 +3888 20 +SET SESSION join_cache_level = DEFAULT; +SET optimizer_switch=@tmp887479_optimizer_switch; +DROP TABLE t1,t2; set @@optimizer_switch=@save_optimizer_switch; |