How to optimize MySQL to insert millions row?

后端 未结 2 642
旧巷少年郎
旧巷少年郎 2020-12-25 10:08

I need to insert millions rows into the MySQL database (InnoDB engine). I have a problem with time when the tables have big sizes. Almost all time is spent on insert queries

2条回答
  •  囚心锁ツ
    2020-12-25 10:48

    If your talking about a large number of INSERT statements, look into something called transactions. I'm quite certain that most (if not all) languages that do SQL support transactions. They will speed up anything involving writing to the DB. An added bonus is that if something goes wrong you can rollback the changes.

提交回复
热议问题