merge into和update性能对比
MERGE INTO语法如下:
MERGE INTO table_name alias1 USING (table|view|sub_query) alias2 ON (join condition) WHEN MATCHED THEN UPDATE table_name SET col1 = col_val1, col2 = col2_val WHEN NOT MATCHED THEN INSERT (column_list) VALUES (column_values);
因为 UPDATE 关联子查询写法,是选到一条做一次子查询,这种写法得更新少,走好的索引才行,MERGE 写法是执行完 ON 后一次性更新,效率会好点。
参考:https://blog.csdn.net/qq_33269520/article/details/78961234