--source include/have_sequence.inc
|
create table t1 (a int, b int, key idx_a(a));
|
insert into t1 select seq, seq from seq_1_to_10;
|
create table t2 as select * from t1;
|
|
--echo # First run SQL with derived merge enabled
|
set optimizer_switch='derived_merge=on';
|
|
--echo # Default join order is t2, t1
|
explain select * from
|
(select /*+ qb_name(qb1)*/ t1.* from t1, t2 where t1.a = t2.a and t1.a < 100) as DT1;
|
|
--echo # Hint applied
|
explain select /*+ join_order(t1@qb1,t2@qb1)*/ * from
|
(select /*+ qb_name(qb1)*/ t1.* from t1, t2 where t1.a = t2.a and t1.a < 100) as DT1;
|
|
--echo # Variation of the same hint but now it is ignored without a warning
|
explain select /*+ join_order(@qb1 t1, t2)*/ * from
|
(select /*+ qb_name(qb1)*/ t1.* from t1, t2 where t1.a = t2.a and t1.a < 100) as DT1;
|
|
--echo # Hint is applied although tables are inside another query block
|
explain select /*+ join_order(t1, t2)*/ * from
|
(select t1.* from t1, t2 where t1.a = t2.a and t1.a < 100) as DT1;
|
|
--echo # Run the same statements with derived merging turned off
|
set optimizer_switch='derived_merge=off';
|
|
--echo # Warning is generated and the hint is ignored despite correct syntax
|
explain select /*+ join_order(t1@qb1,t2@qb1)*/ * from
|
(select /*+ qb_name(qb1)*/ t1.* from t1, t2 where t1.a = t2.a and t1.a < 100) as DT1;
|
|
--echo # Hint is applied, everything is correct
|
explain select /*+ join_order(@qb1 t1, t2)*/ * from
|
(select /*+ qb_name(qb1)*/ t1.* from t1, t2 where t1.a = t2.a and t1.a < 100) as DT1;
|
|
--echo # Warning is generated, it is correct
|
explain select /*+ join_order(t1, t2)*/ * from
|
(select t1.* from t1, t2 where t1.a = t2.a and t1.a < 100) as DT1;
|