Search code examples
mysqlbulkupdate

mysql bulk update performance when `WHERE` filter is not satisfied


bulk update like this:

update table_name set price='x1' where sku='x1'; #updated because sku=x1 exist
update table_name set price='x2' where sku='x2'; #ignored because sku=x2 does not exist
update table_name set price='x3' where sku='x3'; #ignored because sku=x2 does not exist
  ...about 10000 lines...

some lines did not update anything because they do not exist, I want to know, would they make mysql slow OR just affect nothing?


Solution

  • If you have an index on sku, then the updates should have reasonable performance. If they are in a single transaction, then the performance should be okay.

    However, you would be better off putting the new data into a table and using a join for the update.