Skip to content

Commit 8101f1d

Browse files
committed
Bug#21067109: Assert 'join == __NULL' failed in ::optimize()
Patch # 4 of 5 Currently, optimize_cond() builds multiple equalities for all WHERE conditions and all join conditions. But there is one omission: If WHERE condition is NULL, then no multiple equalities are built for any join conditions. This patch fixes that problem by the following logic: - Invoke optimize_cond() when we have a WHERE condition or an outer join (an outer join usually implies at least one join condition). - Inside optimize_cond(), call build_equal_items() whenever there is a join list (ie this is not called for HAVING). - build_equal_items() then inspects the WHERE clause and the various join conditions, and analyzes any conditions that are not NULL. There are several test changes due to this patch. Most changes just reverse the order that operands are tested, this is due to the nature of multiple equality processing. The more interesting test changes are documented below. Test change in main.subquery_sj_all: select * from t1 left join t2 on (t2.A= t1.A And t2.A in (select pk from t10)); Due to multiple equality analysis, a table with REF access is shifted up so that it can be evaluated before a table where table scan is applied. SELECT * FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND (ot1.a, ot2.a) IN (SELECT it1.a, it2.a Due to multiple equality analysis, a join condition can be evaluated earlier than it used to be. Test change in main.derived: SELECT * FROM (SELECT v1.a FROM v1 LEFT OUTER JOIN v2 ON v1.a = v2.b WHERE v1.a = 3 GROUP BY v1.a) p, t q WHERE q.id BETWEEN 1 AND 10; Due to the multiple equality analysis, a "func" ref is changed to a "const", which is slightly simpler to evaluate. Test change in main.join_nested: Two queries have a WHERE clause moved from third to second table in join order. Test change in main.join_outer: Comparison against column is replaced with comparison against literal due to multiple equality analysis.
1 parent 869aeec commit 8101f1d

File tree

66 files changed

+593
-574
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+593
-574
lines changed

mysql-test/r/derived.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,7 +3048,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
30483048
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
30493049
4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
30503050
Warnings:
3051-
Note 1003 /* select#1 */ select `test`.`sq1_t1`.`pk` AS `field1`,`test`.`sq2_t1`.`pk` AS `field2` from `test`.`t2` `table3` left join (`test`.`t2` `sq2_t1`) on(((NULL = `test`.`sq2_t1`.`col_varchar_key`) and (not(<in_optimizer>(`test`.`sq2_t1`.`col_int_key`,<exists>(/* select#4 */ select 1 from `test`.`t2` `child_sq1_t1` where <if>(outer_field_is_not_null, ((<cache>(`test`.`sq2_t1`.`col_int_key`) = NULL) or isnull(NULL)), true) having <if>(outer_field_is_not_null, <is_not_null_test>(NULL), true))))))) left join (`test`.`t1` `sq1_t1`) on((NULL = `test`.`sq2_t1`.`col_varchar_key`))
3051+
Note 1003 /* select#1 */ select `test`.`sq1_t1`.`pk` AS `field1`,`test`.`sq2_t1`.`pk` AS `field2` from `test`.`t2` `table3` left join (`test`.`t2` `sq2_t1`) on(((not(<in_optimizer>(`test`.`sq2_t1`.`col_int_key`,<exists>(/* select#4 */ select 1 from `test`.`t2` `child_sq1_t1` where <if>(outer_field_is_not_null, ((<cache>(`test`.`sq2_t1`.`col_int_key`) = NULL) or isnull(NULL)), true) having <if>(outer_field_is_not_null, <is_not_null_test>(NULL), true))))) and multiple equal(NULL, `test`.`sq2_t1`.`col_varchar_key`))) left join (`test`.`t1` `sq1_t1`) on(multiple equal(NULL, `test`.`sq2_t1`.`col_varchar_key`))
30523052
SELECT table1.pk AS field1,
30533053
table2.pk field2
30543054
FROM (SELECT sq1_t1.*
@@ -3454,9 +3454,9 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
34543454
1 PRIMARY q NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where
34553455
1 PRIMARY <derived2> NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (Block Nested Loop)
34563456
2 DERIVED t NULL ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
3457-
2 DERIVED t NULL ref c2 c2 5 func 2 100.00 Using where; Using index
3457+
2 DERIVED t NULL ref c2 c2 5 const 2 100.00 Using where; Using index
34583458
Warnings:
3459-
Note 1003 /* select#1 */ select `p`.`a` AS `a`,`test`.`q`.`id` AS `id`,`test`.`q`.`c1` AS `c1`,`test`.`q`.`c2` AS `c2` from (/* select#2 */ select `test`.`t`.`c1` AS `a` from `test`.`t` left join (`test`.`t`) on(((`test`.`t`.`c1` = `test`.`t`.`c2`) and (`test`.`t`.`c1` = 10) and (`test`.`t`.`c2` > 3))) where 1 group by `test`.`t`.`c1`) `p` join `test`.`t` `q` where (`test`.`q`.`id` between 1 and 10)
3459+
Note 1003 /* select#1 */ select `p`.`a` AS `a`,`test`.`q`.`id` AS `id`,`test`.`q`.`c1` AS `c1`,`test`.`q`.`c2` AS `c2` from (/* select#2 */ select `test`.`t`.`c1` AS `a` from `test`.`t` left join (`test`.`t`) on(((`test`.`t`.`c1` = 10) and (`test`.`t`.`c2` = 10) and (10 > 3))) where 1 group by `test`.`t`.`c1`) `p` join `test`.`t` `q` where (`test`.`q`.`id` between 1 and 10)
34603460
EXPLAIN SELECT * FROM (SELECT v1.a
34613461
FROM v1 LEFT OUTER JOIN v2 ON v1.a = v2.b
34623462
WHERE v1.a = 3

mysql-test/r/distinct.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
10231023
2 DERIVED it_a NULL ALL NULL NULL NULL NULL 2 100.00 NULL
10241024
2 DERIVED it_b NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop)
10251025
Warnings:
1026-
Note 1003 /* select#1 */ select distinct `subselect`.`b` AS `b` from `test`.`t1` left join (/* select#2 */ select `test`.`it_b`.`a` AS `a`,`test`.`it_b`.`b` AS `b` from `test`.`t1` `it_a` left join `test`.`t1` `it_b` on(TRUE) where 1) `subselect` on((`test`.`t1`.`a` = `subselect`.`b`)) where 1
1026+
Note 1003 /* select#1 */ select distinct `subselect`.`b` AS `b` from `test`.`t1` left join (/* select#2 */ select `test`.`it_b`.`a` AS `a`,`test`.`it_b`.`b` AS `b` from `test`.`t1` `it_a` left join `test`.`t1` `it_b` on(TRUE) where 1) `subselect` on((`subselect`.`b` = `test`.`t1`.`a`)) where 1
10271027
SELECT DISTINCT subselect.b
10281028
FROM t1 LEFT JOIN
10291029
(SELECT it_b.* FROM t1 as it_a LEFT JOIN t1 as it_b ON true) AS subselect
@@ -1057,7 +1057,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
10571057
1 SIMPLE t3 NULL const PRIMARY NULL NULL NULL 1 100.00 Impossible ON condition
10581058
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using temporary; Distinct
10591059
Warnings:
1060-
Note 1003 /* select#1 */ select distinct `test`.`t3`.`a` AS `t3_date` from `test`.`t1` left join `test`.`t3` on((NULL = `test`.`t3`.`b`)) where 1 limit 1
1060+
Note 1003 /* select#1 */ select distinct `test`.`t3`.`a` AS `t3_date` from `test`.`t1` left join `test`.`t3` on(multiple equal(NULL, `test`.`t3`.`b`)) where 1 limit 1
10611061
SELECT DISTINCT t3.a AS t3_date
10621062
FROM t1
10631063
LEFT JOIN t2 ON false

mysql-test/r/explain_for_connection_small_json.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Diff: EXPLAIN NORMAL vs OTHER
307307
@@ -49,4 +50,3 @@
308308
"s1"
309309
- ],
310-
- "attached_condition": "<if>(is_not_null_compl(t2), (`test`.`t1`.`id` = `test`.`t2`.`id`), true)"
310+
- "attached_condition": "<if>(is_not_null_compl(t2), (`test`.`t2`.`id` = `test`.`t1`.`id`), true)"
311311
+ ]
312312
}
313313
QUERY: SELECT * from t1 where a = 1 and b is null order by a desc, b desc

mysql-test/r/explain_json_all.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2463,7 +2463,7 @@ EXPLAIN
24632463
} /* query_block */
24642464
}
24652465
Warnings:
2466-
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,group_concat(`test`.`t2`.`b` separator ',') AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1 group by `test`.`t1`.`a` order by `test`.`t1`.`b`
2466+
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,group_concat(`test`.`t2`.`b` separator ',') AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 group by `test`.`t1`.`a` order by `test`.`t1`.`b`
24672467
DROP TABLE t1;
24682468
DROP TABLE t2;
24692469
#

mysql-test/r/explain_json_none.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2508,7 +2508,7 @@ EXPLAIN
25082508
} /* query_block */
25092509
}
25102510
Warnings:
2511-
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,group_concat(`test`.`t2`.`b` separator ',') AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1 group by `test`.`t1`.`a` order by `test`.`t1`.`b`
2511+
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,group_concat(`test`.`t2`.`b` separator ',') AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 group by `test`.`t1`.`a` order by `test`.`t1`.`b`
25122512
DROP TABLE t1;
25132513
DROP TABLE t2;
25142514
#

mysql-test/r/group_by.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,15 +1967,15 @@ EXPLAIN SELECT MIN(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a;
19671967
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
19681968
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
19691969
Warnings:
1970-
Note 1003 /* select#1 */ select min(`test`.`t2`.`a`) AS `MIN(t2.a)` from `test`.`t2` left join `test`.`t1` on((`test`.`t2`.`a` = `test`.`t1`.`a`))
1970+
Note 1003 /* select#1 */ select min(`test`.`t2`.`a`) AS `MIN(t2.a)` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`a`, `test`.`t1`.`a`))
19711971
SELECT MIN(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a;
19721972
MIN(t2.a)
19731973
1
19741974
EXPLAIN SELECT MAX(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a;
19751975
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
19761976
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
19771977
Warnings:
1978-
Note 1003 /* select#1 */ select max(`test`.`t2`.`a`) AS `MAX(t2.a)` from `test`.`t2` left join `test`.`t1` on((`test`.`t2`.`a` = `test`.`t1`.`a`))
1978+
Note 1003 /* select#1 */ select max(`test`.`t2`.`a`) AS `MAX(t2.a)` from `test`.`t2` left join `test`.`t1` on(multiple equal(`test`.`t2`.`a`, `test`.`t1`.`a`))
19791979
SELECT MAX(t2.a) FROM t2 LEFT JOIN t1 ON t2.a = t1.a;
19801980
MAX(t2.a)
19811981
2

mysql-test/r/group_by_fd_no_prot.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
16481648
1 SIMPLE emp NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort
16491649
1 SIMPLE dept NULL eq_ref PRIMARY PRIMARY 4 test.emp.deptno 1 100.00 NULL
16501650
Warnings:
1651-
Note 1003 /* select#1 */ select `test`.`dept`.`dname` AS `dname`,count(0) AS `COUNT(*)` from `test`.`emp` left join `test`.`dept` on((`test`.`emp`.`deptno` = `test`.`dept`.`deptno`)) where 1 group by `test`.`dept`.`deptno`
1651+
Note 1003 /* select#1 */ select `test`.`dept`.`dname` AS `dname`,count(0) AS `COUNT(*)` from `test`.`emp` left join `test`.`dept` on((`test`.`dept`.`deptno` = `test`.`emp`.`deptno`)) where 1 group by `test`.`dept`.`deptno`
16521652
SELECT dname, COUNT(*)
16531653
FROM empdept
16541654
GROUP BY deptno;

mysql-test/r/group_by_fd_ps_prot.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
10341034
1 SIMPLE emp NULL ALL NULL NULL NULL NULL 1 100.00 Using temporary; Using filesort
10351035
1 SIMPLE dept NULL eq_ref PRIMARY PRIMARY 4 test.emp.deptno 1 100.00 NULL
10361036
Warnings:
1037-
Note 1003 /* select#1 */ select `test`.`dept`.`dname` AS `dname`,count(0) AS `COUNT(*)` from `test`.`emp` left join `test`.`dept` on((`test`.`emp`.`deptno` = `test`.`dept`.`deptno`)) where 1 group by `test`.`dept`.`deptno`
1037+
Note 1003 /* select#1 */ select `test`.`dept`.`dname` AS `dname`,count(0) AS `COUNT(*)` from `test`.`emp` left join `test`.`dept` on((`test`.`dept`.`deptno` = `test`.`emp`.`deptno`)) where 1 group by `test`.`dept`.`deptno`
10381038
SELECT dname, COUNT(*)
10391039
FROM empdept
10401040
GROUP BY deptno;

mysql-test/r/internal_tmp_disk_storage_engine.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ EXPLAIN
112112
"a",
113113
"b"
114114
],
115-
"attached_condition": "<if>(is_not_null_compl(t2), (`test`.`t1`.`b` = `test`.`t2`.`b`), true)"
115+
"attached_condition": "<if>(is_not_null_compl(t2), (`test`.`t2`.`b` = `test`.`t1`.`b`), true)"
116116
}
117117
}
118118
]
119119
}
120120
}
121121
}
122122
Warnings:
123-
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`b` = `test`.`t2`.`b`)) where 1 order by `test`.`t1`.`a`
123+
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`b` = `test`.`t1`.`b`)) where 1 order by `test`.`t1`.`a`
124124
select * from t1 left join t2 on t1.b = t2.b order by t1.a;
125125
a b a b
126126
1 a NULL NULL
@@ -1593,15 +1593,15 @@ EXPLAIN
15931593
"a",
15941594
"b"
15951595
],
1596-
"attached_condition": "<if>(is_not_null_compl(t2), (`test`.`t1`.`a` = `test`.`t2`.`a`), true)"
1596+
"attached_condition": "<if>(is_not_null_compl(t2), (`test`.`t2`.`a` = `test`.`t1`.`a`), true)"
15971597
}
15981598
}
15991599
]
16001600
}
16011601
}
16021602
}
16031603
Warnings:
1604-
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1 order by `test`.`t1`.`b`
1604+
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 order by `test`.`t1`.`b`
16051605
select * from t1 left join t2 on t1.a = t2.a order by t1.b;
16061606
a b a b
16071607
1 ababab NULL NULL

mysql-test/r/join_cache_bka.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
14791479
1 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 8 100.00 Using index; Using temporary; Using filesort
14801480
1 SIMPLE t2 NULL ALL i_a NULL NULL NULL 10 100.00 Using where; Using join buffer (Block Nested Loop)
14811481
Warnings:
1482-
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(`test`.`t2`.`p`) AS `count` from `test`.`t1` left join `test`.`t2` on(((`test`.`t1`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`p` % 2) = 1))) where 1 group by `test`.`t1`.`a`
1482+
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,count(`test`.`t2`.`p`) AS `count` from `test`.`t1` left join `test`.`t2` on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and ((`test`.`t2`.`p` % 2) = 1))) where 1 group by `test`.`t1`.`a`
14831483
select t1.a, count(t2.p) as count
14841484
from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a;
14851485
a count
@@ -2110,7 +2110,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
21102110
1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index
21112111
1 SIMPLE t4 NULL ALL NULL NULL NULL NULL 0 0.00 Using where
21122112
Warnings:
2113-
Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t2` left join (`test`.`t1` join `test`.`t3` left join `test`.`t4` on(1)) on((1 and (`test`.`t1`.`a` = `test`.`t3`.`pk`))) where 1
2113+
Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t2` left join (`test`.`t1` join `test`.`t3` left join `test`.`t4` on(1)) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and 1)) where 1
21142114
SELECT 1
21152115
FROM t2 LEFT JOIN
21162116
((t1 JOIN t3 ON t1.a = t3.pk)
@@ -2161,7 +2161,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
21612161
1 SIMPLE t3 NULL ALL PRIMARY NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop)
21622162
1 SIMPLE t4 NULL index carrier_id carrier_id 5 NULL 2 100.00 Using where; Using index; Using join buffer (Block Nested Loop)
21632163
Warnings:
2164-
Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`carrier` = `test`.`t1`.`carrier`) and (`test`.`t3`.`id` = `test`.`t4`.`carrier_id`))) where 1
2164+
Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t2` join `test`.`t1` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`carrier_id` = `test`.`t3`.`id`) and (`test`.`t3`.`carrier` = `test`.`t1`.`carrier`))) where 1
21652165

21662166
DROP TABLE t1,t2,t3,t4;
21672167
#
@@ -2562,7 +2562,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
25622562
1 SIMPLE t1 NULL index col_int_key,col_varchar_key col_varchar_key 7 NULL 3 100.00 Using index; Using temporary; Using filesort
25632563
1 SIMPLE t2 NULL ref col_varchar_key col_varchar_key 3 test.t1.col_varchar_key 1 100.00 Using join buffer (Batched Key Access)
25642564
Warnings:
2565-
Note 1003 /* select#1 */ select min(`test`.`t2`.`col_datetime_key`) AS `field1`,`test`.`t1`.`col_int_key` AS `field2` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`col_varchar_key`) on((`test`.`t1`.`col_varchar_key` = `test`.`t2`.`col_varchar_key`)) where 1 group by `field2` order by `field1`
2565+
Note 1003 /* select#1 */ select min(`test`.`t2`.`col_datetime_key`) AS `field1`,`test`.`t1`.`col_int_key` AS `field2` from `test`.`t1` left join `test`.`t2` FORCE INDEX (`col_varchar_key`) on((`test`.`t2`.`col_varchar_key` = `test`.`t1`.`col_varchar_key`)) where 1 group by `field2` order by `field1`
25662566
SELECT MIN(t2.col_datetime_key) AS field1,
25672567
t1.col_int_key AS field2
25682568
FROM t1
@@ -2622,7 +2622,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
26222622
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort
26232623
1 SIMPLE t1 NULL ref col_int_key col_int_key 4 test.t2.pk 2 100.00 Using join buffer (Batched Key Access)
26242624
Warnings:
2625-
Note 1003 /* select#1 */ select `test`.`t2`.`col_varchar_key` AS `field1`,count(distinct `test`.`t1`.`col_varchar_nokey`) AS `COUNT(DISTINCT t1.col_varchar_nokey)`,`test`.`t2`.`pk` AS `field4` from `test`.`t2` left join `test`.`t1` on((`test`.`t2`.`pk` = `test`.`t1`.`col_int_key`)) where 1 group by `field1`,`field4` order by `test`.`t1`.`col_datetime_key`
2625+
Note 1003 /* select#1 */ select `test`.`t2`.`col_varchar_key` AS `field1`,count(distinct `test`.`t1`.`col_varchar_nokey`) AS `COUNT(DISTINCT t1.col_varchar_nokey)`,`test`.`t2`.`pk` AS `field4` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`col_int_key` = `test`.`t2`.`pk`)) where 1 group by `field1`,`field4` order by `test`.`t1`.`col_datetime_key`
26262626
SELECT t2.col_varchar_key AS field1 , COUNT(DISTINCT t1.col_varchar_nokey), t2.pk AS field4
26272627
FROM t1
26282628
RIGHT JOIN t2 ON t2.pk = t1.col_int_key
@@ -2728,7 +2728,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
27282728
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop)
27292729
1 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t2.pk 1 100.00 Using join buffer (Batched Key Access)
27302730
Warnings:
2731-
Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `t2_pk`,`test`.`t4`.`pk` AS `t4_pk`,`test`.`t4`.`k` AS `t4_k`,`test`.`t4`.`i` AS `t4_i` from `test`.`t1` left join `test`.`t2` on((`test`.`t1`.`k` = `test`.`t2`.`pk`)) left join `test`.`t3` on(`test`.`t3`.`i`) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where 1
2731+
Note 1003 /* select#1 */ select `test`.`t2`.`pk` AS `t2_pk`,`test`.`t4`.`pk` AS `t4_pk`,`test`.`t4`.`k` AS `t4_k`,`test`.`t4`.`i` AS `t4_i` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`pk` = `test`.`t1`.`k`)) left join `test`.`t3` on(`test`.`t3`.`i`) left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t2`.`pk`)) where 1
27322732
SELECT t2.pk as t2_pk, t4.pk as t4_pk, t4.k as t4_k, t4.i
27332733
as t4_i FROM t1
27342734
LEFT JOIN t2 ON t1.k = t2.pk

0 commit comments

Comments
 (0)