How does MySQL handle concurrent inserts?

If you will create a new connection to the database and perform inserts from both the links, then from the database’s perspective, it will still be sequential.

The documentation of Concurrent Inserts for MyISAM on the MySQL’s documentation page says something like this:

If MyISAM storage is used and table has no holes, multiple INSERT statements are queued and performed in sequence, concurrently with the SELECT statements.

Mind that there is no control over the order in which two concurrent inserts will take place. The order in this concurrency is at the mercy of a lot of different factors. To ensure order, by default you will have to sacrifice concurrency.

Leave a Comment