在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