#
# Test of GROUP BY ... ORDER BY NULL optimization
#

create table t1 (a int not null, b int not null);
insert into t1 values (1,1),(1,2),(3,1),(3,2),(2,2),(2,1);
create table t2 (a int not null, b int not null, key(a));
insert into t2 values (1,3),(3,1),(2,2),(1,1);
select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
drop table t1,t2;

diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result
index a6da0e70247..f28068cc29a 100644
--- a/mysql-test/main/group_by.result
+++ b/mysql-test/main/group_by.result
@@ -536,17 +536,17 @@ a b
 select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
 a      b
 1      3
+1      1
 3      1
 2      2
-1      1
 explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
 id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
-1      SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    6       Using temporary; Using filesort
-1      SIMPLE  t2      ALL     a       NULL    NULL    NULL    4       Using where; Using join buffer (flat, BNL join)
+1      SIMPLE  t2      ALL     a       NULL    NULL    NULL    4       Using temporary; Using filesort
+1      SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    6       Using where; Using join buffer (flat, BNL join)
 explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
 id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
-1      SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    6       Using temporary
-1      SIMPLE  t2      ALL     a       NULL    NULL    NULL    4       Using where; Using join buffer (flat, BNL join)
+1      SIMPLE  t2      ALL     a       NULL    NULL    NULL    4       Using temporary
+1      SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    6       Using where; Using join buffer (flat, BNL join)
MDEV-10177 Invisible Columns and Invisible Index
Functional test

explain select * from t1,t2 where t1.b = t2.c and t1.c = t2.b;
 id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
-1      SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    10      
-1      SIMPLE  t1      ALL     b,c     NULL    NULL    NULL    10      Using where; Using join buffer (flat, BNL join)
+1      SIMPLE  t1      ALL     b,c     NULL    NULL    NULL    10      
+1      SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    10      Using where; Using join buffer (flat, BNL join)


Fixed bug mdev-10454.
range.result

--echo # join order: (t1,t2) with ref access of t2 
--echo # range access to t1 by 1-component keys for index idx
So we can change this test to use old defaults

@@ -2529,8 +2533,8 @@ insert into t2 values
 explain select * from t1,t2
 where a = d and (a,e) in ((3,3),(7,7),(8,8)) and length(f) = 1;
 id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
-1      SIMPLE  t1      range   idx     idx     5       NULL    6       Using index condition
-1      SIMPLE  t2      ref     idx1,idx2       idx1    5       test.t1.a       12      Using where
+1      SIMPLE  t2      range   idx1,idx2       idx1    5       NULL    8       Using index condition; Using where
+1      SIMPLE  t1      ref     idx     idx     5       test.t2.d       8 














MDEV-16386 [this test also does not depend on the join order]
derived_cond_pushdown.test

 explain select * from v1,t2 where (v1.b=t2.b) and (v1.a<5);
 id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
-1      PRIMARY t2      ALL     NULL    NULL    NULL    NULL    9       
-1      PRIMARY <derived2>      ALL     NULL    NULL    NULL    NULL    5       Using where; Using join buffer (flat, BNL join)
+1      PRIMARY <derived2>      ALL     NULL    NULL    NULL    NULL    5       Using where
+1      PRIMARY t2      ALL     NULL    NULL    NULL    NULL    9       Using where; Using join buffer (flat, BNL join)
 2      DERIVED t3      range   i1      i1      5       NULL    5       Using index condition



diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result
index 404d878a9ec..5b45fa08e1e 100644
--- a/mysql-test/main/subselect.result
+++ b/mysql-test/main/subselect.result

 MDEV-435
Again doesn’t look like join order is important here

@@ -7019,8 +7019,8 @@ SELECT * FROM t1
 WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
 id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 1      PRIMARY t1      index   a       a       5       NULL    2       Using where; Using index
-2      SUBQUERY        <subquery3>     ALL     distinct_key    NULL    NULL    NULL    1       
-2      SUBQUERY        t2      ALL     NULL    NULL    NULL    NULL    2       Using where; Using join buffer (flat, BNL join)
+2      SUBQUERY        t2      ALL     NULL    NULL    NULL    NULL    2       Using where
+2      SUBQUERY        <subquery3>     eq_ref  distinct_key    distinct_key    4       test.t2.c       1       
 3      MATERIALIZED    t3      ALL     NULL    NULL    NULL    NULL    2       









diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result
index 884451d7dff..78df07667f9 100644
--- a/mysql-test/main/subselect_sj2_mat.result
+++ b/mysql-test/main/subselect_sj2_mat.result
@@ -1853,18 +1853,18 @@ AND t3.id_product IN (SELECT id_product FROM t2 t2_3 WHERE t2_3.id_t2 = 18 OR t2
 AND t3.id_product IN (SELECT id_product FROM t2 t2_4 WHERE t2_4.id_t2 = 34 OR t2_4.id_t2 = 23) 
 AND t3.id_product IN (SELECT id_product FROM t2 t2_5 WHERE t2_5.id_t2 = 29 OR t2_5.id_t2 = 28 OR t2_5.id_t2 = 26);
 id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
-1      PRIMARY t1      index   NULL    PRIMARY 8       NULL    73      Using index
-1      PRIMARY t3      eq_ref  PRIMARY PRIMARY 4       test.t1.id_product      1       Using index
+1      PRIMARY <subquery3>     ALL     distinct_key    NULL    NULL    NULL    12      
+1      PRIMARY t3      eq_ref  PRIMARY PRIMARY 4       test.t2_2.id_product    1       Using where; Using index
 1      PRIMARY <subquery5>     eq_ref  distinct_key    distinct_key    4       func    1       Using where
-1      PRIMARY <subquery4>     eq_ref  distinct_key    distinct_key    4       func    1       Using where
-1      PRIMARY <subquery3>     eq_ref  distinct_key    distinct_key    4       func    1       Using where
-1      PRIMARY <subquery2>     eq_ref  distinct_key    distinct_key    4       func    1       Using where
-1      PRIMARY t4      eq_ref  PRIMARY PRIMARY 8       test.t1.id_product,const        1       Using where; Using index
-1      PRIMARY <subquery6>     eq_ref  distinct_key    distinct_key    4       func    1       Using where
 1      PRIMARY t5      ALL     NULL    NULL    NULL    NULL    18      Using where; Using join buffer (flat, BNL join)
+1      PRIMARY <subquery6>     eq_ref  distinct_key    distinct_key    4       func    1       Using where
+1      PRIMARY t4      eq_ref  PRIMARY PRIMARY 8       test.t3.id_product,const        1       Using where; Using index
+1      PRIMARY <subquery2>     eq_ref  distinct_key    distinct_key    4       func    1       Using where
+1      PRIMARY <subquery4>     eq_ref  distinct_key    distinct_key    4       func    1       Using where
+1      PRIMARY t1      index   NULL    PRIMARY 8       NULL    73      Using where; Using index; Using join buffer (flat, BNL join)
+3      MATERIALIZED    t2_2    ref     id_t2,id_product        id_t2   5       const   12      Using where
 5      MATERIALIZED    t2_4    range   id_t2,id_product        id_t2   5       NULL    18      Using index condition; Using where
-4      MATERIALIZED    t2_3    range   id_t2,id_product        id_t2   5       NULL    32      Using index condition; Using where
-3      MATERIALIZED    t2_2    ref     id_t2,id_product        id_t2   5       const   12      
-2      MATERIALIZED    t2_1    ref     id_t2,id_product        id_t2   5       const   50      
 6      MATERIALIZED    t2_5    range   id_t2,id_product        id_t2   5       NULL    30      Using index condition; Using where
+2      MATERIALIZED    t2_1    ref     id_t2,id_product        id_t2   5       const   50      
+4      MATERIALIZED    t2_3    range   id_t2,id_product        id_t2   5       NULL    32      Using index condition; Using where


diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result
index 983c6c31c65..ce9aa2d6c40 100644
--- a/mysql-test/main/subselect_sj_mat.result
+++ b/mysql-test/main/subselect_sj_mat.result

@@ -459,15 +459,15 @@ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and
 a1 = c1;
 id     select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 1      PRIMARY t1      ALL     NULL    NULL    NULL    NULL    3       100.00  Using where
+1      PRIMARY <subquery4>     ALL     distinct_key    NULL    NULL    NULL    4       100.00  Using where
 1      PRIMARY t3      ALL     NULL    NULL    NULL    NULL    4       100.00  Using where; Using join buffer (flat, BNL join)
-1      PRIMARY <subquery4>     eq_ref  distinct_key    distinct_key    16      func,func       1       100.00  
 4      MATERIALIZED    t3      ALL     NULL    NULL    NULL    NULL    4       100.00  Using where
-4      MATERIALIZED    t2i     index   it2i1,it2i2,it2i3       it2i3   18      NULL    5       80.00   Using where; Using index; Using join buffer (flat, BNL join)
+4      MATERIALIZED    t2i     ref     it2i1,it2i2,it2i3       it2i3   18      test.t3.c1,test.t3.c2   2       100.00  Using index
 2      DEPENDENT SUBQUERY      t1      ALL     NULL    NULL    NULL    NULL    3       100.00  Using where
 3      DEPENDENT UNION t2      ALL     NULL    NULL    NULL    NULL    5       100.00  Using where
 NULL   UNION RESULT    <union2,3>      ALL     NULL    NULL    NULL    NULL    NULL    NULL    
 Warnings:
-Note   1003    /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t3` where `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and `test`.`t3`.`c2` > '0'
+Note   1003    /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t3` where `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and `test`.`t3`.`c2` = `test`.`t3`.`c2` and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and `test`.`t3`.`c2` > '0'























stat_tables.test
Functional test 


Was added in commit
commit 1c0a89afcc1581187e8ee84abbd445da2bfa45d9
Author: Igor Babaev <igor@askmonty.org>
Date:   Wed Apr 11 17:14:06 2012 -0700

    The pilot implementation of mwl#250: Use the statistics from persistent
    statistical tables instead of the statistics provided by engine.


let $Q5=
select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
      and l_suppkey = s_suppkey and c_nationkey = s_nationkey
      and s_nationkey = n_nationkey and n_regionkey = r_regionkey
      and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
      and o_orderdate < date '1995-01-01' + interval '1' year
group by n_name
order by revenue desc;



diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result
index 3ebc3b47833..fe3c83d5a23 100644
--- a/mysql-test/main/stat_tables.result
+++ b/mysql-test/main/stat_tables.result
@@ -64,12 +64,12 @@ and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01'
 group by n_name
 order by revenue desc;
 id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
-1      SIMPLE  orders  range   PRIMARY,i_o_orderdate,i_o_custkey       i_o_orderdate   4       NULL    179     Using where; Using temporary; Using filesort
-1      SIMPLE  customer        eq_ref  PRIMARY,i_c_nationkey   PRIMARY 4       dbt3_s001.orders.o_custkey      1       Using where
-1      SIMPLE  nation  eq_ref  PRIMARY,i_n_regionkey   PRIMARY 4       dbt3_s001.customer.c_nationkey  1       
-1      SIMPLE  region  ALL     PRIMARY NULL    NULL    NULL    5       Using where; Using join buffer (flat, BNL join)
+1      SIMPLE  region  ALL     PRIMARY NULL    NULL    NULL    5       Using where; Using temporary; Using filesort
+1      SIMPLE  nation  ref     PRIMARY,i_n_regionkey   i_n_regionkey   5       dbt3_s001.region.r_regionkey    5       
+1      SIMPLE  supplier        ref     PRIMARY,i_s_nationkey   i_s_nationkey   5       dbt3_s001.nation.n_nationkey    1
       
+1      SIMPLE  customer        ref     PRIMARY,i_c_nationkey   i_c_nationkey   5       dbt3_s001.nation.n_nationkey    6
       
+1      SIMPLE  orders  ref     PRIMARY,i_o_orderdate,i_o_custkey       i_o_custkey     5       dbt3_s001.customer.c_custkey
    15      Using where
 1      SIMPLE  lineitem        ref     PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity  PRIMARY 4       dbt3_s001.orders.o_orderkey     4       Using where
-1      SIMPLE  supplier        eq_ref  PRIMARY,i_s_nationkey   PRIMARY 4       dbt3_s001.lineitem.l_suppkey    1       Using where


join_cache.result


diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result
index fde6e0fec6b..79a4bf9730d 100644
--- a/mysql-test/main/join_cache.result
+++ b/mysql-test/main/join_cache.result
@@ -79,9 +79,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where
+1	SIMPLE	City	ALL	NULL	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where; Using join buffer (flat, BNL join)
 1	SIMPLE	CountryLanguage	ALL	NULL	NULL	NULL	NULL	984	Using where; Using join buffer (flat, BNL join)
-1	SIMPLE	City	ALL	NULL	NULL	NULL	NULL	4079	Using where; Using join buffer (flat, BNL join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -157,9 +157,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where
-1	SIMPLE	CountryLanguage	ALL	NULL	NULL	NULL	NULL	984	Using where; Using join buffer (flat, BNL join)
-1	SIMPLE	City	ALL	NULL	NULL	NULL	NULL	4079	Using where; Using join buffer (incremental, BNL join)
+1	SIMPLE	City	ALL	NULL	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where; Using join buffer (flat, BNL join)
+1	SIMPLE	CountryLanguage	ALL	NULL	NULL	NULL	NULL	984	Using where; Using join buffer (incremental, BNL join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -236,8 +236,8 @@ CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where
-1	SIMPLE	CountryLanguage	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	984	Using where; Using join buffer (flat, BNLH join)
 1	SIMPLE	City	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	4079	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	CountryLanguage	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	984	Using where; Using join buffer (flat, BNLH join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -314,8 +314,8 @@ CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where
-1	SIMPLE	CountryLanguage	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	984	Using where; Using join buffer (flat, BNLH join)
-1	SIMPLE	City	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	4079	Using where; Using join buffer (incremental, BNLH join)
+1	SIMPLE	City	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	4079	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	CountryLanguage	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	984	Using where; Using join buffer (incremental, BNLH join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -402,7 +402,7 @@ ON City.Country=Country.Code AND City.Population > 5000000
 WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where
-1	SIMPLE	City	hash_range	City_Population	#hash#$hj:City_Population	3:4	world.Country.Code	25	Using where; Rowid-ordered scan; Using join buffer (flat, BNLH join)
+1	SIMPLE	City	range	City_Population	City_Population	4	NULL	25	Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
 SELECT Country.Name, Country.Population, City.Name, City.Population 
 FROM Country LEFT JOIN City
 ON City.Country=Country.Code AND City.Population > 5000000
@@ -497,9 +497,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where
+1	SIMPLE	City	ALL	NULL	NULL	NULL	NULL	4079	Using where
 1	SIMPLE	CountryLanguage	ALL	NULL	NULL	NULL	NULL	984	Using where; Using join buffer (flat, BNL join)
-1	SIMPLE	City	ALL	NULL	NULL	NULL	NULL	4079	Using where; Using join buffer (flat, BNL join)
+1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where; Using join buffer (flat, BNL join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -575,9 +575,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where
+1	SIMPLE	City	ALL	NULL	NULL	NULL	NULL	4079	Using where
 1	SIMPLE	CountryLanguage	ALL	NULL	NULL	NULL	NULL	984	Using where; Using join buffer (flat, BNL join)
-1	SIMPLE	City	ALL	NULL	NULL	NULL	NULL	4079	Using where; Using join buffer (incremental, BNL join)
+1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where; Using join buffer (incremental, BNL join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -653,9 +653,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where
-1	SIMPLE	CountryLanguage	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	984	Using where; Using join buffer (flat, BNLH join)
-1	SIMPLE	City	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	4079	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	City	ALL	NULL	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	hash_ALL	NULL	#hash#$hj	3	world.City.Country	984	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	Country	hash_ALL	NULL	#hash#$hj	3	world.City.Country	239	Using where; Using join buffer (flat, BNLH join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -731,9 +731,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	Country	ALL	NULL	NULL	NULL	NULL	239	Using where
-1	SIMPLE	CountryLanguage	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	984	Using where; Using join buffer (flat, BNLH join)
-1	SIMPLE	City	hash_ALL	NULL	#hash#$hj	3	world.Country.Code	4079	Using where; Using join buffer (incremental, BNLH join)
+1	SIMPLE	City	ALL	NULL	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	hash_ALL	NULL	#hash#$hj	3	world.City.Country	984	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	Country	hash_ALL	NULL	#hash#$hj	3	world.City.Country	239	Using where; Using join buffer (incremental, BNLH join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -848,9 +848,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	hash_ALL	PRIMARY	#hash#PRIMARY	3	world.CountryLanguage.Country	239	Using where; Using join buffer (flat, BNLH join)
-1	SIMPLE	City	hash_ALL	Country	#hash#Country	3	world.CountryLanguage.Country	4079	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	hash_ALL	PRIMARY,Percentage	#hash#PRIMARY	3	world.City.Country	984	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	Country	hash_ALL	PRIMARY	#hash#PRIMARY	3	world.City.Country	239	Using where; Using join buffer (flat, BNLH join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -1048,9 +1048,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	hash_ALL	PRIMARY	#hash#PRIMARY	3	world.CountryLanguage.Country	239	Using where; Using join buffer (flat, BNLH join)
-1	SIMPLE	City	hash_ALL	Country	#hash#Country	3	world.CountryLanguage.Country	4079	Using where; Using join buffer (incremental, BNLH join)
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	hash_ALL	PRIMARY,Percentage	#hash#PRIMARY	3	world.City.Country	984	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	Country	hash_ALL	PRIMARY	#hash#PRIMARY	3	world.City.Country	239	Using where; Using join buffer (incremental, BNLH join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -1278,7 +1278,7 @@ WHERE City.Country=Country.Code AND
 Country.Name LIKE 'L%' AND City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name FROM City,Country
 WHERE City.Country=Country.Code AND 
 Country.Name LIKE 'L%' AND City.Population > 100000;
@@ -1307,9 +1307,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.CountryLanguage.Country	1	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-1	SIMPLE	City	ref	Country	Country	3	world.CountryLanguage.Country	18	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	ref	PRIMARY,Percentage	PRIMARY	3	world.City.Country	4	Using index condition(BKA); Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.City.Country	1	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -1318,41 +1318,41 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 Name	Name	Language
-La Matanza	Argentina	Spanish
 Lomas de Zamora	Argentina	Spanish
+La Matanza	Argentina	Spanish
 Lauro de Freitas	Brazil	Portuguese
 Los Angeles	Chile	Spanish
 Las Palmas de Gran Canaria	Spain	Spanish
-L´Hospitalet de Llobregat	Spain	Spanish
 Lleida (Lérida)	Spain	Spanish
+L´Hospitalet de Llobregat	Spain	Spanish
 Liupanshui	China	Chinese
-Lianyungang	China	Chinese
 Liangcheng	China	Chinese
+Lianyungang	China	Chinese
 Lengshuijiang	China	Chinese
 Lázaro Cárdenas	Mexico	Spanish
 Lagos de Moreno	Mexico	Spanish
 Las Margaritas	Mexico	Spanish
 Lashio (Lasho)	Myanmar	Burmese
 Lalitapur	Nepal	Nepali
-Ludwigshafen am Rhein	Germany	German
 Leverkusen	Germany	German
+Ludwigshafen am Rhein	Germany	German
 Luchou	Taiwan	Min
 Lungtan	Taiwan	Min
 Lower Hutt	New Zealand	English
 Los Teques	Venezuela	Spanish
 Leninsk-Kuznetski	Russian Federation	Russian
-Los Angeles	United States	English
 Long Beach	United States	English
 Lexington-Fayette	United States	English
 Louisville	United States	English
 Little Rock	United States	English
+Los Angeles	United States	English
 EXPLAIN
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
@@ -1475,7 +1475,7 @@ WHERE City.Country=Country.Code AND
 Country.Name LIKE 'L%' AND City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name FROM City,Country
 WHERE City.Country=Country.Code AND 
 Country.Name LIKE 'L%' AND City.Population > 100000;
@@ -1504,9 +1504,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.CountryLanguage.Country	1	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-1	SIMPLE	City	ref	Country	Country	3	world.CountryLanguage.Country	18	Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	ref	PRIMARY,Percentage	PRIMARY	3	world.City.Country	4	Using index condition(BKA); Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.City.Country	1	Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -1515,41 +1515,41 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 Name	Name	Language
-La Matanza	Argentina	Spanish
 Lomas de Zamora	Argentina	Spanish
+La Matanza	Argentina	Spanish
 Lauro de Freitas	Brazil	Portuguese
 Los Angeles	Chile	Spanish
 Las Palmas de Gran Canaria	Spain	Spanish
-L´Hospitalet de Llobregat	Spain	Spanish
 Lleida (Lérida)	Spain	Spanish
+L´Hospitalet de Llobregat	Spain	Spanish
 Liupanshui	China	Chinese
-Lianyungang	China	Chinese
 Liangcheng	China	Chinese
 Lengshuijiang	China	Chinese
-Lázaro Cárdenas	Mexico	Spanish
-Lagos de Moreno	Mexico	Spanish
+Lianyungang	China	Chinese
 Las Margaritas	Mexico	Spanish
+Lagos de Moreno	Mexico	Spanish
+Lázaro Cárdenas	Mexico	Spanish
 Lashio (Lasho)	Myanmar	Burmese
 Lalitapur	Nepal	Nepali
-Ludwigshafen am Rhein	Germany	German
 Leverkusen	Germany	German
+Ludwigshafen am Rhein	Germany	German
 Luchou	Taiwan	Min
 Lungtan	Taiwan	Min
 Lower Hutt	New Zealand	English
 Los Teques	Venezuela	Spanish
 Leninsk-Kuznetski	Russian Federation	Russian
-Los Angeles	United States	English
-Long Beach	United States	English
-Lexington-Fayette	United States	English
-Louisville	United States	English
 Little Rock	United States	English
+Louisville	United States	English
+Lexington-Fayette	United States	English
+Long Beach	United States	English
+Los Angeles	United States	English
 EXPLAIN
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
@@ -1672,7 +1672,7 @@ WHERE City.Country=Country.Code AND
 Country.Name LIKE 'L%' AND City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name FROM City,Country
 WHERE City.Country=Country.Code AND 
 Country.Name LIKE 'L%' AND City.Population > 100000;
@@ -1701,9 +1701,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.CountryLanguage.Country	1	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
-1	SIMPLE	City	ref	Country	Country	3	world.CountryLanguage.Country	18	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	ref	PRIMARY,Percentage	PRIMARY	3	world.City.Country	4	Using index condition(BKA); Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.City.Country	1	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -1716,37 +1716,37 @@ La Matanza	Argentina	Spanish
 Lomas de Zamora	Argentina	Spanish
 Lauro de Freitas	Brazil	Portuguese
 Los Angeles	Chile	Spanish
+Lleida (Lérida)	Spain	Spanish
 Las Palmas de Gran Canaria	Spain	Spanish
 L´Hospitalet de Llobregat	Spain	Spanish
-Lleida (Lérida)	Spain	Spanish
-Liupanshui	China	Chinese
 Lianyungang	China	Chinese
 Liangcheng	China	Chinese
 Lengshuijiang	China	Chinese
-Lázaro Cárdenas	Mexico	Spanish
+Liupanshui	China	Chinese
 Lagos de Moreno	Mexico	Spanish
 Las Margaritas	Mexico	Spanish
+Lázaro Cárdenas	Mexico	Spanish
 Lashio (Lasho)	Myanmar	Burmese
 Lalitapur	Nepal	Nepali
-Ludwigshafen am Rhein	Germany	German
 Leverkusen	Germany	German
+Ludwigshafen am Rhein	Germany	German
 Luchou	Taiwan	Min
 Lungtan	Taiwan	Min
 Lower Hutt	New Zealand	English
 Los Teques	Venezuela	Spanish
 Leninsk-Kuznetski	Russian Federation	Russian
-Los Angeles	United States	English
-Long Beach	United States	English
 Lexington-Fayette	United States	English
 Louisville	United States	English
+Los Angeles	United States	English
 Little Rock	United States	English
+Long Beach	United States	English
 EXPLAIN
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
@@ -1869,7 +1869,7 @@ WHERE City.Country=Country.Code AND
 Country.Name LIKE 'L%' AND City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name FROM City,Country
 WHERE City.Country=Country.Code AND 
 Country.Name LIKE 'L%' AND City.Population > 100000;
@@ -1898,9 +1898,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.CountryLanguage.Country	1	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
-1	SIMPLE	City	ref	Country	Country	3	world.CountryLanguage.Country	18	Using where; Using join buffer (incremental, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	ref	PRIMARY,Percentage	PRIMARY	3	world.City.Country	4	Using index condition(BKA); Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.City.Country	1	Using where; Using join buffer (incremental, BKAH join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -1913,28 +1913,28 @@ La Matanza	Argentina	Spanish
 Lomas de Zamora	Argentina	Spanish
 Lauro de Freitas	Brazil	Portuguese
 Los Angeles	Chile	Spanish
+Lleida (Lérida)	Spain	Spanish
 Las Palmas de Gran Canaria	Spain	Spanish
 L´Hospitalet de Llobregat	Spain	Spanish
-Lleida (Lérida)	Spain	Spanish
-Liupanshui	China	Chinese
 Lianyungang	China	Chinese
 Liangcheng	China	Chinese
 Lengshuijiang	China	Chinese
-Lázaro Cárdenas	Mexico	Spanish
+Liupanshui	China	Chinese
 Lagos de Moreno	Mexico	Spanish
+Lázaro Cárdenas	Mexico	Spanish
 Las Margaritas	Mexico	Spanish
 Lashio (Lasho)	Myanmar	Burmese
 Lalitapur	Nepal	Nepali
-Ludwigshafen am Rhein	Germany	German
 Leverkusen	Germany	German
+Ludwigshafen am Rhein	Germany	German
 Luchou	Taiwan	Min
 Lungtan	Taiwan	Min
 Lower Hutt	New Zealand	English
 Los Teques	Venezuela	Spanish
 Leninsk-Kuznetski	Russian Federation	Russian
+Lexington-Fayette	United States	English
 Los Angeles	United States	English
 Long Beach	United States	English
-Lexington-Fayette	United States	English
 Louisville	United States	English
 Little Rock	United States	English
 EXPLAIN
@@ -1943,7 +1943,7 @@ WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AN
 City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
@@ -2099,9 +2099,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	hash_ALL	PRIMARY	#hash#PRIMARY	3	world.CountryLanguage.Country	239	Using where; Using join buffer (flat, BNLH join)
-1	SIMPLE	City	hash_ALL	Country	#hash#Country	3	world.CountryLanguage.Country	4079	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	hash_ALL	PRIMARY,Percentage	#hash#PRIMARY	3	world.City.Country	984	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	Country	hash_ALL	PRIMARY	#hash#PRIMARY	3	world.City.Country	239	Using where; Using join buffer (flat, BNLH join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -2203,9 +2203,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	hash_ALL	PRIMARY	#hash#PRIMARY	3	world.CountryLanguage.Country	239	Using where; Using join buffer (flat, BNLH join)
-1	SIMPLE	City	hash_ALL	Country	#hash#Country	3	world.CountryLanguage.Country	4079	Using where; Using join buffer (incremental, BNLH join)
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	hash_ALL	PRIMARY,Percentage	#hash#PRIMARY	3	world.City.Country	984	Using where; Using join buffer (flat, BNLH join)
+1	SIMPLE	Country	hash_ALL	PRIMARY	#hash#PRIMARY	3	world.City.Country	239	Using where; Using join buffer (incremental, BNLH join)
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -2278,7 +2278,7 @@ WHERE City.Country=Country.Code AND
 Country.Name LIKE 'L%' AND City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name FROM City,Country
 WHERE City.Country=Country.Code AND 
 Country.Name LIKE 'L%' AND City.Population > 100000;
@@ -2307,9 +2307,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.CountryLanguage.Country	1	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-1	SIMPLE	City	ref	Country	Country	3	world.CountryLanguage.Country	18	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	ref	PRIMARY,Percentage	PRIMARY	3	world.City.Country	4	Using index condition(BKA); Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.City.Country	1	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -2352,7 +2352,7 @@ WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AN
 City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
@@ -2382,7 +2382,7 @@ WHERE City.Country=Country.Code AND
 Country.Name LIKE 'L%' AND City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name FROM City,Country
 WHERE City.Country=Country.Code AND 
 Country.Name LIKE 'L%' AND City.Population > 100000;
@@ -2411,9 +2411,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.CountryLanguage.Country	1	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-1	SIMPLE	City	ref	Country	Country	3	world.CountryLanguage.Country	18	Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	ref	PRIMARY,Percentage	PRIMARY	3	world.City.Country	4	Using index condition(BKA); Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.City.Country	1	Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -2456,7 +2456,7 @@ WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AN
 City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
@@ -2486,7 +2486,7 @@ WHERE City.Country=Country.Code AND
 Country.Name LIKE 'L%' AND City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name FROM City,Country
 WHERE City.Country=Country.Code AND 
 Country.Name LIKE 'L%' AND City.Population > 100000;
@@ -2515,9 +2515,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.CountryLanguage.Country	1	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
-1	SIMPLE	City	ref	Country	Country	3	world.CountryLanguage.Country	18	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	ref	PRIMARY,Percentage	PRIMARY	3	world.City.Country	4	Using index condition(BKA); Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.City.Country	1	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -2534,12 +2534,12 @@ Las Palmas de Gran Canaria	Spain	Spanish
 L´Hospitalet de Llobregat	Spain	Spanish
 Lleida (Lérida)	Spain	Spanish
 Liupanshui	China	Chinese
-Lianyungang	China	Chinese
 Liangcheng	China	Chinese
+Lianyungang	China	Chinese
 Lengshuijiang	China	Chinese
 Lázaro Cárdenas	Mexico	Spanish
-Lagos de Moreno	Mexico	Spanish
 Las Margaritas	Mexico	Spanish
+Lagos de Moreno	Mexico	Spanish
 Lashio (Lasho)	Myanmar	Burmese
 Lalitapur	Nepal	Nepali
 Ludwigshafen am Rhein	Germany	German
@@ -2549,9 +2549,9 @@ Lungtan	Taiwan	Min
 Lower Hutt	New Zealand	English
 Los Teques	Venezuela	Spanish
 Leninsk-Kuznetski	Russian Federation	Russian
+Lexington-Fayette	United States	English
 Los Angeles	United States	English
 Long Beach	United States	English
-Lexington-Fayette	United States	English
 Louisville	United States	English
 Little Rock	United States	English
 EXPLAIN
@@ -2560,7 +2560,7 @@ WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AN
 City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
@@ -2590,7 +2590,7 @@ WHERE City.Country=Country.Code AND
 Country.Name LIKE 'L%' AND City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name FROM City,Country
 WHERE City.Country=Country.Code AND 
 Country.Name LIKE 'L%' AND City.Population > 100000;
@@ -2619,9 +2619,9 @@ City.Name LIKE 'L%' AND Country.Population > 3000000 AND
 CountryLanguage.Percentage > 50 AND
 LENGTH(Language) < LENGTH(City.Name) - 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	CountryLanguage	ALL	PRIMARY,Percentage	NULL	NULL	NULL	984	Using where
-1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.CountryLanguage.Country	1	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
-1	SIMPLE	City	ref	Country	Country	3	world.CountryLanguage.Country	18	Using where; Using join buffer (incremental, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	City	ALL	Country	NULL	NULL	NULL	4079	Using where
+1	SIMPLE	CountryLanguage	ref	PRIMARY,Percentage	PRIMARY	3	world.City.Country	4	Using index condition(BKA); Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	SIMPLE	Country	eq_ref	PRIMARY	PRIMARY	3	world.City.Country	1	Using where; Using join buffer (incremental, BKAH join); Key-ordered Rowid-ordered scan
 SELECT City.Name, Country.Name, CountryLanguage.Language
 FROM City,Country,CountryLanguage
 WHERE City.Country=Country.Code AND
@@ -2664,7 +2664,7 @@ WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AN
 City.Population > 100000;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	Country	range	PRIMARY,Name	Name	52	NULL	10	Using index condition; Rowid-ordered scan
-1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	18	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
+1	PRIMARY	City	ref	Population,Country	Country	3	world.Country.Code	17	Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
 SELECT Name FROM City
 WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND
 City.Population > 100000;
@@ -3044,7 +3044,7 @@ id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 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	t9	ref	PRIMARY,t9_subgenreid,t9_metaid	t9_metaid	4	test.t1.metaid	2	Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
 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
 SELECT t1.uniquekey, t1.xml AS affiliateXml,
@@ -3665,8 +3665,8 @@ where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c;
 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	5	test.t1.b	1	
-1	SIMPLE	t3	ref	idx	idx	5	test.t1.d	1	
 1	SIMPLE	t4	ref	idx	idx	5	test.t1.c	1	
+1	SIMPLE	t3	ref	idx	idx	5	test.t1.d	1	
 select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4
 where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c;
 a	b	c	d	e	f	g
@@ -3678,8 +3678,8 @@ where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c;
 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	5	test.t1.b	1	Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-1	SIMPLE	t3	ref	idx	idx	5	test.t1.d	1	Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
 1	SIMPLE	t4	ref	idx	idx	5	test.t1.c	1	Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
+1	SIMPLE	t3	ref	idx	idx	5	test.t1.d	1	Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
 select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4
 where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c;
 a	b	c	d	e	f	g













join_outer_innodb
diff --git a/mysql-test/main/join_outer_innodb.result b/mysql-test/main/join_outer_innodb.result
index 6f3fb09329d..9ab8bde1236 100644
--- a/mysql-test/main/join_outer_innodb.result
+++ b/mysql-test/main/join_outer_innodb.result
@@ -440,18 +440,18 @@ id        select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 1      SIMPLE  t6      eq_ref  PRIMARY PRIMARY 4       test.t1.a3      1       Using where; Using index
 1      SIMPLE  t8      eq_ref  PRIMARY PRIMARY 1       test.t1.a4      1       Using index
 1      SIMPLE  t7      eq_ref  PRIMARY PRIMARY 1       test.t1.a7      1       
-1      SIMPLE  t9      ref     PRIMARY PRIMARY 1       test.t1.a4      1       
 1      SIMPLE  t11     eq_ref  PRIMARY PRIMARY 4       test.t1.a5      1       
 1      SIMPLE  t12     eq_ref  PRIMARY PRIMARY 4       test.t11.k3     1       Using where
 1      SIMPLE  l2      eq_ref  PRIMARY PRIMARY 4       test.t11.k4     1       Using where
 1      SIMPLE  t13     ref     PRIMARY,m3      PRIMARY 4       test.t1.a1      1       Using where; Using index
+1      SIMPLE  t9      ref     PRIMARY PRIMARY 1       test.t1.a4      1       
 1      SIMPLE  l4      eq_ref  PRIMARY PRIMARY 4       test.t13.m2     1       Using where; Using index
 1      SIMPLE  m2      ref     PRIMARY,m3      PRIMARY 4       test.t1.a1      1       Using where; Using index
-1      SIMPLE  l3      eq_ref  PRIMARY PRIMARY 4       test.m2.m2      1       Using where
+1      SIMPLE  l3      ALL     PRIMARY NULL    NULL    NULL    3       Using where; Using join buffer (flat, BNL join)
+1      SIMPLE  t10     ALL     PRIMARY NULL    NULL    NULL    3       Using where; Using join buffer (incremental, BNL join)
 1      SIMPLE  t14     eq_ref  PRIMARY PRIMARY 2       test.t1.a8      1       Using where
 1      SIMPLE  t15     eq_ref  PRIMARY PRIMARY 2       test.t1.a9      1       Using where; Using index
 1      SIMPLE  t16     ref     PRIMARY PRIMARY 2       test.t15.o1     1       Using where
-1      SIMPLE  t10     ALL     PRIMARY NULL    NULL    NULL    3       Using where; Using join buffer (flat, BNL join)
 explain select * from v1;
 id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 1      SIMPLE  t1      ALL     a4,a6,a5,a7     NULL    NULL    NULL    3       Using where
@@ -462,18 +462,18 @@ id        select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 1      SIMPLE  t6      eq_ref  PRIMARY PRIMARY 4       test.t1.a3      1       Using where; Using index
 1      SIMPLE  t8      eq_ref  PRIMARY PRIMARY 1       test.t1.a4      1       Using index
 1      SIMPLE  t7      eq_ref  PRIMARY PRIMARY 1       test.t1.a7      1       
-1      SIMPLE  t9      ref     PRIMARY PRIMARY 1       test.t1.a4      1       
 1      SIMPLE  t11     eq_ref  PRIMARY PRIMARY 4       test.t1.a5      1       
 1      SIMPLE  t12     eq_ref  PRIMARY PRIMARY 4       test.t11.k3     1       Using where
 1      SIMPLE  l2      eq_ref  PRIMARY PRIMARY 4       test.t11.k4     1       Using where
 1      SIMPLE  t13     ref     PRIMARY,m3      PRIMARY 4       test.t1.a1      1       Using where; Using index
+1      SIMPLE  t9      ref     PRIMARY PRIMARY 1       test.t1.a4      1       
 1      SIMPLE  l4      eq_ref  PRIMARY PRIMARY 4       test.t13.m2     1       Using where; Using index
 1      SIMPLE  m2      ref     PRIMARY,m3      PRIMARY 4       test.t1.a1      1       Using where; Using index
-1      SIMPLE  l3      eq_ref  PRIMARY PRIMARY 4       test.m2.m2      1       Using where
+1      SIMPLE  l3      ALL     PRIMARY NULL    NULL    NULL    3       Using where; Using join buffer (flat, BNL join)
+1      SIMPLE  t10     ALL     PRIMARY NULL    NULL    NULL    3       Using where; Using join buffer (incremental, BNL join)
 1      SIMPLE  t14     eq_ref  PRIMARY PRIMARY 2       test.t1.a8      1       Using where
 1      SIMPLE  t15     eq_ref  PRIMARY PRIMARY 2       test.t1.a9      1       Using where; Using index
 1      SIMPLE  t16     ref     PRIMARY PRIMARY 2       test.t15.o1     1       Using where
-1      SIMPLE  t10     ALL     PRIMARY NULL    NULL    NULL    3       Using where; Using join buffer (flat, BNL join)
 drop view v1;
 drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16;


