How to improve INSERT performance on a very large MySQL table

后端 未结 4 638
刺人心
刺人心 2020-12-17 21:14

I am working on a large MySQL database and I need to improve INSERT performance on a specific table. This one contains about 200 Millions rows and its structure is as follow

4条回答
  •  我在风中等你
    2020-12-17 22:09

    Your linear key on name and the large indexes slows things down.

    LINEAR KEY needs to be calculated every insert. http://dev.mysql.com/doc/refman/5.1/en/partitioning-linear-hash.html

    can you show us some example data of file_to_process.csv maybe a better schema should be build.

    Edit looked more closely

    INSERT INTO items (name, key, busy, created_at, updated_at) 
    (
        SELECT temp_items.name, temp_items.key, temp_items.busy, temp_items.created_at, temp_items.updated_at 
        FROM temp_items
    ) 
    

    this will proberly will create a disk temp table, this is very very slow so you should not use it to get more performance or maybe you should check some mysql config settings like tmp-table-size and max-heap-table-size maybe these are misconfigured.

提交回复
热议问题