insert into table1 ...;
update table2 set count=count+1;
The above inserts something into table1, and if it succeeds, updates the field count table2.
Of course, such things can be handled by transactions, but transactions should block the table, which will not be effective in a high parallel system. And it could be even worse if you need to update multiple tables in this transaction.
What is your decision?
I use PHP and I implement transactions as follows:
mysql_query('begin');
mysql_query($statement1);
mysql_query($statement2);
...
mysql_query('commit');
So it looks like all the tables listed in these $statementwill be locked?
source
share