Tuesday, February 12, 2008

MySQL sql udpate - multiple table syntax


update polleddata pd set pd.absolutelastcountervalue=
( select lastcountervalue
from v2r2_temp_tbl1 vtt
where vtt.id=pd.id);

will run 15 minutes for 8000+ records. Change it to:

update polleddata pd, v2r2_temp_tbl1 vtt
set pd.absolutelastcountervalue=vtt.lastcountervalue
where pd.id=vtt.id;

has much better performance.

No comments: