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

SQL新手求教这段有无优化空间?
SQL code

create temporary table tbd(id int) select id from d where para <> 1234;

delete from t1 where id in (select id from tbd);
delete from t2 where id in (select id from tbd);
delete from t3 where id in (select id from tbd);
delete from t4 where id in (select id from tbd);

drop table tbd;



新手求教,有无改进空间?怎么改进?

------解决方案--------------------
delete t1 from t1,d where t1.id=d.id;
delete t1 from t2,d where t2.id=d.id;
delete t1 from t3,d where t3.id=d.id;
delete t1 from t4,d where t4.id=d.id;
------解决方案--------------------
explain ...不就知道了吗
------解决方案--------------------
探讨

引用:

delete t1 from t1,d where t1.id=d.id;
delete t1 from t2,d where t2.id=d.id;
delete t1 from t3,d where t3.id=d.id;
delete t1 from t4,d where t4.id=d.id;


这样直接删除,比先select出来再删除快吗?……