Hello.
There is a script in which certain actions are performed with fields in the database:
Extract from table A data for row B and field C - the value of D = 0.
For a while something to consider.
new_D = D + 1.
The update to table A, the data for row B and field C are the value of new_D.
If this script is called 10 times at the same time, will the requests in MySQl be queued or will Phase 1 and 4 be executed at stage 2 with other parallel calls?
It does not happen that 10 parallel calls will lead to the fact that in the table there will be D = 1, not 10?
If there is no strictly formed queue for the execution of all script requests, then give info on how to work with this case correctly.
I came across the use of LOCK TABLES, and the thought appeared that the script was a curve ...
Thanks in advance for your help.
Dvalue, then maybe you should just do it: UPDATE A SET C = C + 1 WHERE B = ... Then after each update the value will increase by one and it doesn’t matter in which order the requests come. - BOPOHSELECT ... FOR UPDATE- seems to block only the necessary rows, and you can continue working with the rest of the lines (which is better than full blocking throughLOCK TABLES) - BOPOH...FOR UPDATE- should help, or come up with a different approach. The main thing is that the rest of the requests were waiting for their turn. - BOPOH