在MySQL中,不存在于更新语句需要更多的时间
update table1 t1
set column1 = 100,
column2 = 200
where column3 > 500
and not exists(select *
from table2
where column1 = t1.column1);
这个查询是太耗费时间执行,确实有重写的任何其他更快捷的方式。
为表2 ID是主柱,所以我想我可以改写为
update table1 t1
set column1 = 100,
column2 = 200
where column3 > 500
and not exists(select ID
from table2
where column1 = t1.column1);
但仍查询需要2秒来运行,我想在的毫秒的东西。
它更新了多少条记录? – 2010-10-26 23:35:17
表1:200K表2:150 K记录。 – Sharpeye500 2010-10-26 23:40:09