日期:2014-05-16  浏览次数:20744 次

关于mysql关联子查询与非关联子查询的问题
select * from t1 where x in (select x from t2)


为什么表t4的查询计划结果是DEPENDENT SUBQUERY 依赖外部查询的子查询


用extended+show warnings得到重建后的查询
select `test`.`t3`.`x` AS `x`,`test`.`t3`.`y` AS `y` from `test`.`t3` where <in_optimizer>(`test`.`t3`.`x`,<exists>(select 1 from `test`.`t4` where (<cache>(`test`.`t3`.`x`) = `test`.`t4`.`x`)))

请问为什么这样优化呢, 效率很高吗??????????????????????????

------解决方案--------------------
select * from t1,t2 where t1.x=t2.x
------解决方案--------------------
select * from t1,t2
where t1.x=t2.x;