Is MySQL UPDATE incrementing operation transaction-safe? I mean could it possible to get into the race condition while many concurrent clients execute queries like "UPDATE table SET field=field+1"? If 1000 clients will execute such query simultaneously, what value that field will be set, 1000 greater than before?
+1
A:
Yes. Each Update statement locks either entire table (MyISAM) or a single row (InnoDB) and other statements are queued until the lock is released.
Now, if you run each of these statements in transaction, you might actually run into a deadlock.
Mchl
2010-09-04 08:05:25