2010-10-22 17:35:27 +00:00
|
|
|
# test that the query planner picks clustering keys for joins
|
|
|
|
|
|
|
|
# create table s
|
2010-10-27 18:45:26 +00:00
|
|
|
--disable_warnings
|
2010-10-22 17:35:27 +00:00
|
|
|
drop table if exists s;
|
2010-10-27 18:45:26 +00:00
|
|
|
--enable_warnings
|
2010-10-22 17:35:27 +00:00
|
|
|
create table s (a int, b int, c int) engine=tokudb;
|
|
|
|
|
|
|
|
# populate table s
|
|
|
|
let $a = 10;
|
|
|
|
while ($a) {
|
|
|
|
let $b = 10;
|
|
|
|
while ($b) {
|
|
|
|
let $c = 10;
|
|
|
|
while ($c) {
|
|
|
|
eval insert into s values ($a,$b,$c);
|
|
|
|
dec $c;
|
|
|
|
}
|
|
|
|
dec $b;
|
|
|
|
}
|
|
|
|
dec $a;
|
|
|
|
}
|
|
|
|
|
|
|
|
# create table t
|
2010-10-27 18:45:26 +00:00
|
|
|
--disable_warnings
|
2010-10-22 17:35:27 +00:00
|
|
|
drop table if exists t;
|
2010-10-27 18:45:26 +00:00
|
|
|
--enable_warnings
|
2010-10-22 17:35:27 +00:00
|
|
|
create table t like s;
|
|
|
|
insert into t select * from s;
|
|
|
|
|
|
|
|
# join with no keys
|
|
|
|
show create table s;
|
|
|
|
show create table t;
|
|
|
|
explain select straight_join * from s,t where s.b = t.b;
|
|
|
|
|
|
|
|
# join with uncovered keys
|
|
|
|
alter table s add key(b);
|
|
|
|
alter table t add key(b);
|
|
|
|
show create table s;
|
|
|
|
show create table t;
|
|
|
|
explain select straight_join * from s,t where s.b = t.b;
|
|
|
|
|
|
|
|
# join with uncovered keys and clustering keys
|
|
|
|
alter table s add clustering key(b);
|
|
|
|
alter table t add clustering key(b);
|
|
|
|
show create table s;
|
|
|
|
show create table t;
|
|
|
|
explain select straight_join * from s,t where s.b = t.b;
|
|
|
|
|
|
|
|
# join with clustering keys
|
|
|
|
alter table s drop key b;
|
|
|
|
alter table t drop key b;
|
|
|
|
show create table s;
|
|
|
|
show create table t;
|
|
|
|
explain select straight_join * from s,t where s.b = t.b;
|
|
|
|
|
|
|
|
# put the uncovered keys back
|
|
|
|
alter table s add key(b);
|
|
|
|
alter table t add key(b);
|
|
|
|
show create table s;
|
|
|
|
show create table t;
|
|
|
|
explain select straight_join * from s,t where s.b = t.b;
|
|
|
|
|
2010-11-11 12:54:00 +00:00
|
|
|
# cleanup
|
|
|
|
drop table s,t;
|