mysql - Is this the wrong way to go about updating a table -
i wrote code try update q_id column of table q_id values of table b. feel if inefficient , wrong way go because it's taking long time run. there better way this?
update tbl1 a,tbl2 b set a.q_id = b.q_id a.col not null , a.col = b.col
your query equivalent to:
update tbl1 join tbl2 b on a.col = b.col set a.q_id = b.q_id; the comparison null unnecessary.
however, not performance. index on tbl2(q_id, col) should performance considerably.
if updating lots of rows (says hundreds of thousands or more), have deal logging issues. in case, breaking update multiple steps might wise option. also, if there multiple matches each record in tbl1, might slow down query.
Comments
Post a Comment