I think Baron was referring to a technique like this:
you sell a t-shirt, UPDATE table SET t=t-X WHERE t = X, if you get rows
affected, it's sold and ok. if not, the stock ran out before the operation. but
it's safe. see
http://dev.mysql.com/tech-resources/articles/storage-engine/part_3.html
On Fri, Jan 15, 2010 at 2:54 AM, Johan Machielse
johan.machie...@kpnplanet.nl wrote:
The problem is that multiple users can read and update the same field
simultaneously (worse case) which could lead to unpredictable problems.
There are other ways to do handle most cases. For example:
UPDATE
Hi,
I have created a query to read and update a stock item by using the FOR UPDATE
statement. According to the MySql documention only the rows that are selected
using the FOR UPDATE should be locked for other sessions, but somehow whole the
table is locked. This post gives some general
Johan,
I don't see a valid need for using FOR UPDATE here. In fact, FOR
UPDATE is the cause of many grievances, and I would advise you to
avoid it by any means possible. Among other things, it will cause
serious performance problems when your server gets busy. And as you
can see, it's hard to
Hi Baron,
Thank you for your answer.
The problem is that multiple users can read and update the same field
simultaneously (worse case) which could lead to unpredictable problems.
According to the MySql online documentation
(http://dev.mysql.com/doc/refman/5.0/en/innodb-locking-reads.html)