有同事说我的sql语句存在效率问题我原来的语句是:
select a_id form t_a where a_id in (select o_id from t_o where t=3 and s=10)同事说a_id虽然是主键也是索引,但是并未起到索引作用经过优化后的语句:
select a_id form t_a where a_id in (select o_id from (select o_id from t_o where t=3 and s=10) t)各位的看法如何?
select a_id form t_a where a_id in (select o_id from t_o where t=3 and s=10)同事说a_id虽然是主键也是索引,但是并未起到索引作用经过优化后的语句:
select a_id form t_a where a_id in (select o_id from (select o_id from t_o where t=3 and s=10) t)各位的看法如何?
改成
select a_id from t_a A,t_o B
where A.a_id=B.o_id and B.t=3 and B.s=10;
[求证&散分]MySQL 中 where id in (1,2,3,4,...) 的效率问题讨论