mysql - Why is this update query so slow and how can I improve it -


i'm trying set av.unittype values in ut.unittype, long 3 columns match, , wondering parts of statement causing take long:

set sql_safe_updates=0; update `db`.`table_av` av, `db`.`table_ut` ut  set av.unittype = ut.unittype trim(leading '0' av.id) = ut.id , av.veh = ut.veh , av.date concat('%', ut.year); 

change join used syntax

set sql_safe_updates=0;  update `db`.`table_av` av,      join `db`.`table_ut` ut          on trim(leading '0' av.id) = ut.id             , av.veh = ut.veh             , av.date concat('%', ut.year);     set av.unittype = ut.unittype 

that last line should use date functions instead of (if possible). better yet, make sure 2 columns compatible types in each table (ie timestamp, or @ least 4 digit years in int or varchar.


Comments