Loading Data Efficiently

Most of the time you'll probably be concerned about optimizing SELECT queries, because they are the most common type of query and because it's not always straightforward to figure out how to optimize them. By comparison, loading data into your database is straightforward. Nevertheless, there are strategies you can use to improve the efficiency of data-loading operations. The basic principles are as follows:

  • Bulk loading is faster than single-row loading because the index cache need not be flushed after each record is loaded; it can be flushed at the end of the batch of records.

  • Loading is faster when a table has no indexes than when it is indexed. If there are indexes, not only must the record be added to the data file, ...

Get MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.