Mysql: A large amount of data is inserted into the same table. Why is multi-threaded insertion faster than single-threaded insertion?

  mysql, question

http://blog.csdn.net/javastar …
https://www.cnblogs.com/fanwe …

Look at these articles and insert a lot of data into the same table in mysql database.
Multi-threaded insertion is faster than single-threaded insertion.

My feeling is that threads should be exclusive in writing the same table
Otherwise, how to check the unique index
How does mysql determine the primary key id when it grows its own id?

If exclusive
Why is multi-threaded insertion faster than single-threaded insertion?

The use of the word thread here may give rise to some ambiguities. The official saying is: operations. In other words, the integration of [multiple single entry insertion operations] into [one multiple entry insertion operation] is the basis for improving the speed of Insert. The reason is very simple. When inserting the data inside, the overall time allocation is as follows:

  1. Link Time (30%)
  2. Send query to Server (20%)
  3. Resolve query (20%)
  4. Insert operation (10% x number of entries)
  5. Insert index (10% x number of indexes)
  6. Close link (10%)

The above percentages are the approximate ones given by the government. It can be seen from here that the real time-consuming process is not the operation, but the linking and parsing process, which is the root cause why the time-consuming time of [multiple single entry insertion operation] is higher than that of [one multiple entry insertion operation].

Official link