开发者

How to improve MySQL INSERT and UPDATE performance?

开发者 https://www.devze.com 2022-12-21 22:24 出处:网络
Performance of INSERT and UPDATE statements in our database seems to be degrading and causing poor performance in our web app.

Performance of INSERT and UPDATE statements in our database seems to be degrading and causing poor performance in our web app.

Tables are InnoDB and the application uses transactions. Are there any easy tweaks that I can make to speed things up?

I think we might be seeing some lock开发者_Go百科ing issues, how can I find out?


  • You could change the settings to speed InnoDB inserts up.
  • And even more ways to speed up InnoDB
  • ...and one more optimization article


INSERT and UPDATE get progressively slower when the number of rows increases on a table with an index. Innodb tables are even slower than MyISAM tables for inserts and the delayed key write option is not available.

The most effective way to speed things up would be to save the data first into a flat file and then do LOAD DATA , this is about 20x faster.

The second option would be create a temporary in memory table, load the data into it and then do a INSERT INTO SELECT in batches. That is once you have about 100 rows in your temp table, load them into the permanent one.

Additionally you can get an small improvement in speed by moving the Index file into a separate physical hard drive from the one where the data file is stored. Also try to move any bin logs into a different device. Same applies for the temporary file location.


I would try setting your tables to delay index updates.

ALTER TABLE {name} delay_key_write='1'


If you are not using indexes, they can help improve performance of update queries.


I would not look at locking/blocking unless the number of concurrent users have been increasing over time.

If the performance gradually degraded over time I would look at the query plans with the EXPLAIN statement.

It would be helpful to have the results of these from the development or initial production environment, for comparison purposes.

Dropping or adding an index may be needed, or some other maintenance action specified in other posts.

0

精彩评论

暂无评论...
验证码 换一张
取 消