开发者

Mysql UPDATE incrementing

开发者 https://www.devze.com 2023-01-15 07:16 出处:网络
Is MySQL UPDATE incrementing operatio开发者_如何学Gon transaction-safe? I mean could it possible to get into the race condition while many concurrent clients execute queries like \"UPDATE table SET fi

Is MySQL UPDATE incrementing operatio开发者_如何学Gon 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消