日期:2014-05-16 浏览次数:20856 次
delete table1,table2 from table1 inner join table2 where table1.id = table2.id and table1.type = 'music'
delete table1,table2 from table1 inner join table2 on table1.id = table2.id where table1.type = 'music'
------解决方案--------------------
与连接数没关系。那1000个连接是指用户连接。
你的这个SQL语句慢可能的原因,
1) 查询速度慢,你的连接查询后产生大量记录,或者表中没有适当的索引。
2)其它并发用户锁定了表,造成了你的等待。
------解决方案--------------------
在mysql中inner join完全等同于,
好汉可以试试
delete table1,table2 from table1 ,table2 where table1.id = table2.id and table1.type = 'music'
------解决方案--------------------
检查一下索引情况,在ID上有索引?
------解决方案--------------------
create table delete_id as select table1.id from table1 inner join table2 on table1.id = table2.id where table1.type = 'music'; create index indx1 on delete_id(id); delete from table1 where id in(select id from delete_id); delete from table2 where id in(select id from delete_id);
------解决方案--------------------
truncate table delete_id; drop table delete_id;