Why do MySQL InnoDB inserts / updates on large tables get very slow when there are a few indexes?

前端 未结 5 1043
忘掉有多难
忘掉有多难 2020-12-14 02:48

We have a series of tables that have grown organically to several million rows, in production doing an insert or update can take up to two seconds. However if I dump the tab

5条回答
  •  生来不讨喜
    2020-12-14 03:10

    Could it be due to fragmentation of XFS?

    Copy/pasted from http://stevesubuntutweaks.blogspot.com/2010/07/should-you-use-xfs-file-system.html :

    To check the fragmentation level of a drive, for example located at /dev/sda6:

    sudo xfs_db -c frag -r /dev/sda6

    The result will look something like so:

    actual 51270, ideal 174, fragmentation factor 99.66%

    That is an actual result I got from the first time I installed these utilities, previously having no knowledge of XFS maintenance. Pretty nasty. Basically, the 174 files on the partition were spread over 51270 separate pieces. To defragment, run the following command:

    sudo xfs_fsr -v /dev/sda6

    Let it run for a while. the -v option lets it show the progress. After it finishes, try checking the fragmentation level again:

    sudo xfs_db -c frag -r /dev/sda6

    actual 176, ideal 174, fragmentation factor 1.14%

    Much better!

提交回复
热议问题