In depth mysql concurrent insertion optimization

  • 2020-05-19 06:05:21
  • OfStack

When using storm to process logs, I often encounter the efficiency problem of concurrent insertion of mysql. I checked some information on the Internet and made a note

Change the engine of the table to myisam,

Modify concurrent_insert=2 for my.cnf,concurrent_insert can be set to 0, 1, 2, 2 is fully supported for concurrent insertion

1) concurrent _insert =0, concurrent insert is not allowed regardless of whether there is any free space left in the middle of MyISAM's table data file due to deletion.

2) concurrent_insert = 1, when there is no free space in the data file of MyISAM storage engine table, Concurrent Insert is conducted from the end of the file.

3) concurrent_insert = 2, concurrent insert operation is allowed at the end of the data file, regardless of whether there is any free space left by deletion in the middle part of the table data file of MyISAM storage engine.

Restart mysql: / etc init d/mysqld restart

When inserting data, it can also be set to delayed insert: insert delayed into 'tablename'...


Related articles: