How does MySQL handle concurrent inserts?

后端 未结 4 1112
情歌与酒
情歌与酒 2020-12-05 06:41

I know there is one issue in MySQL with concurrent SELECT and INSERT. However, my question is if I open up two connections with MySQL and keep loading data using both of the

4条回答
  •  生来不讨喜
    2020-12-05 07:14

    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 on the MySQL's documentation page says:

    If there are multiple INSERT statements, they 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.

提交回复
热议问题