In-depth explanation of mysql concurrent insertion optimization bitsCN.com
When using storm to process logs, we often encounter the efficiency problem of inserting mysql concurrently. I checked some information online and made some notes.
Change the table engine to myisam,
Modify the concurrent_insert = 2 of my. cnf. The value of concurrent_insert can be 0 1 2, and 2 completely supports concurrent inserts.
1) concurrent _ insert = 0,Concurrent insert is not allowed no matter whether the table data file in MyISAM is deleted and leaves Russian free space.
2) concurrent_insert = 1,When there is no free space in the data file of the MyISAM storage engine table, run Concurrent Insert from the end of the file.
3) concurrent_insert = 2,Whether the middle part of the table data file of the MyISAM storage engine exists free space due to deletion, the concurrent insert operation can be performed at the end of the data file.
Restart mysql:/etc/init. d/mysqld restart
When inserting data, you can also set it to delayed insert: insert delayed into 'tablename '......
BitsCN.com