~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to mysql-test/r/subselect_sj.result

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
A confluent case of dependency
23
23
explain select * from t1 where a in (select a from t10 where pk=12);
24
24
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
25
 
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    3       
26
 
1       PRIMARY t10     const   PRIMARY PRIMARY 4       const   1       Using where
 
25
1       PRIMARY NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
27
26
select * from t1 where a in (select a from t10 where pk=12);
28
27
a       b
 
28
explain select * from t1 where a in (select a from t10 where pk=9);
 
29
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
30
1       PRIMARY t10     const   PRIMARY PRIMARY 4       const   1       
 
31
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    3       Using where
 
32
select * from t1 where a in (select a from t10 where pk=9);
 
33
a       b
29
34
An empty table inside
30
35
explain select * from t1 where a in (select a from t11);
31
36
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
60
65
1       PRIMARY t10     eq_ref  PRIMARY PRIMARY 4       test.t1.a       1       100.00  
61
66
1       PRIMARY t12     eq_ref  PRIMARY PRIMARY 4       test.t10.a      1       100.00  Using index
62
67
Warnings:
63
 
Note    1003    select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (`test`.`t10` join `test`.`t12`) join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`))
 
68
Note    1003    select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`))
64
69
subqueries within outer joins go into ON expr.
65
70
explAin extended
66
71
select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A And B.A in (select pk from t10));
70
75
1       PRIMARY B       ALL     NULL    NULL    NULL    NULL    3       100.00  
71
76
1       PRIMARY t10     eq_ref  PRIMARY PRIMARY 4       test.B.A        1       100.00  Using index
72
77
Warnings:
73
 
Note    1003    select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join ((`test`.`t10`) join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`A`.`A` = `test`.`t1`.`A`) And 1 And (`test`.`B`.`A` = `test`.`t10`.`pk`))) where 1
 
78
Note    1003    select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`A`.`A` = `test`.`t1`.`A`) And 1 And (`test`.`B`.`A` = `test`.`t10`.`pk`))) where 1
74
79
t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)"
75
80
explAin extended
76
81
select * from t1 left join t2 on (t2.A= t1.A And t2.A in (select pk from t10));
79
84
1       PRIMARY t2      ALL     NULL    NULL    NULL    NULL    3       100.00  
80
85
1       PRIMARY t10     eq_ref  PRIMARY PRIMARY 4       test.t2.A       1       100.00  Using index
81
86
Warnings:
82
 
Note    1003    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`.`t10`) join `test`.`t2`) on(((`test`.`t2`.`A` = `test`.`t1`.`A`) And 1 And (`test`.`t2`.`A` = `test`.`t10`.`pk`))) where 1
 
87
Note    1003    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`.`t10` join `test`.`t2`) on(((`test`.`t2`.`A` = `test`.`t1`.`A`) And 1 And (`test`.`t2`.`A` = `test`.`t10`.`pk`))) where 1
83
88
we shouldn't flatten if we're going to get a join of > MAX_TABLES.
84
89
explain select * from 
85
90
t1 s00, t1 s01,  t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09,
188
193
insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B;
189
194
explain extended select * from t1 where a in (select pk from t10 where pk<3);
190
195
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
191
 
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    103     100.00  Using where
192
 
1       PRIMARY t10     eq_ref  PRIMARY PRIMARY 4       test.t1.a       1       100.00  Using index
 
196
1       PRIMARY t10     range   PRIMARY PRIMARY 4       NULL    4       100.00  Using where; Using index
 
197
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    103     100.00  Using where; Using join buffer
193
198
Warnings:
194
 
Note    1003    select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from (`test`.`t10`) join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 3))
 
199
Note    1003    select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3))
195
200
drop table t0, t1;
196
201
drop table t10, t11, t12;