Home > database >  How to speed up the execution of the mysql
How to speed up the execution of the mysql

Time:10-11

Bb table is empty, the InnoDB engine, the use of stored procedure insert 5000 records need 12 seconds, how to speed up the point

CodePudding user response:

This sp, you is a simple insert operations, insert the main bottleneck in IO, the most common solution to this problem is the combination of insert, reduce the number of IO,
For example:
Instead of
Insert into game. ` bb ` values (I), (I + 1), (I + 2),... (I + 500)
The set I=I + 501

An insert 500, circulation 10 times to complete,

CodePudding user response:

Each time all is slow as a transaction in the treatment of the insert. Mysql underlying will write log information in addition to insert the data. The bulk insert upstairs is a good way. There is also a practice. As a transaction to deal with. In theory this way is faster than your way but slower than the bulk insert upstairs

CodePudding user response:

This cycle is to insert this data?
It can advance in database to build such a table, direct
The situation of the insert into the table to select the table can do an insert, why walk cycle
  • Related