What is the best way to achieve speedy inserts of large amounts of data in MySQL?

后端 未结 6 1569
无人共我
无人共我 2021-01-05 05:01

I have written a program in C to parse large XML files and then create files with insert statements. Some other process would ingest the files into a MySQL database. This

6条回答
  •  一个人的身影
    2021-01-05 05:21

    1. Make sure you use a transaction.

    Transactions eliminate the

    INSERT, SYNC-TO-DISK

    repetition phase and instead all the disk IO is performed when you COMMIT the transaction.

    2. Make sure to utilize connection compression

    Raw text + GZip compressed stream ~= as much as 90% bandwidth saving in some cases.

    3. Utilise the parallel insert notation where possible

    INSERT INTO TableName(Col1,Col2) VALUES (1,1),(1,2),(1,3) 
    

    ( Less text to send, shorter action )

提交回复
热议问题