At some points, many of our customers need to handle insertions of large data sets and run into slow insert statements. This article will try to give some guidance on how to speed up slow INSERT SQL queries.
The following recommendations may help optimize your data loading operations:
-
Remove existing indexes - Inserting data to a MySQL table will slow down once you add more and more indexes. Therefore, if you're loading data to a new table, it's best to load it to a table without any indexes, and only then create the indexes, once the data was loaded.
When you're inserting records, the database needs to update the indexes on every insert, which is costly in terms of performance. It's much faster to insert all records without indexing them, and then create the indexes once for the entire table.
…