In the PHP System, 100 people simultaneously process mysql insert operations. What are the types of optimized code writing tables? myisam and concurrent operations,
Do you need to lock the table as described below?
Or will mysql automatically process 100 requests in queue
Mysql_query ("lock tables 'user' WRITE"); // LOCK the 'user' table $ SQL = "INSERT INTO 'user' ('id', 'username ', 'Sex ') VALUES (NULL, 'test1', '0') "; $ res = mysql_query ($ SQL); if ($ res) {echo' submitted successfully .! ';} Else {echo' failed! ';} Mysql_query ("unlock tables"); // UNLOCK
Reply to discussion (solution)
No need to lock the table during insertion (but you can append the clause that is inserted when Idle)
The table can be locked only when it is modified.
However, it is unreasonable to allow multiple users to modify a record at the same time. Business flow problems
Insert is an atomic operation and does not need to lock the table. It will automatically lock itself.
Here is a scenario description for inserting 100 people at the same time.
No matter how many users you insert at the same time, the database will be written successively, but the user does not feel it
Is the new record added by the landlord's plug-in pure?