mysql 不满足“WHERE”过滤器时的批量更新性能
mysql bulk update performance when `WHERE` filter is not satisfied
像这样批量更新:
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...
有些行没有更新任何东西,因为它们不存在,我想知道,它们会使 mysql 变慢还是什么都不影响?
如果您在 sku
上有索引,那么 updates
应该有合理的性能。如果他们在单个事务中,那么性能应该没问题。
但是,您最好将新数据放入 table 并使用 join
作为 update
。
像这样批量更新:
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...
有些行没有更新任何东西,因为它们不存在,我想知道,它们会使 mysql 变慢还是什么都不影响?
如果您在 sku
上有索引,那么 updates
应该有合理的性能。如果他们在单个事务中,那么性能应该没问题。
但是,您最好将新数据放入 table 并使用 join
作为 update
。