8.2.5.1 Optimizing INSERT Statements优化INSERT语句

To optimize insert speed, combine many small operations into a single large operation. Ideally, you make a single connection, send the data for many new rows at once, and delay all index updates and consistency checking until the very end.要优化插入速度,请将许多小操作合并到单个大操作中。理想情况下,只建立一个连接,一次发送多个新行的数据,并将所有索引更新和一致性检查延迟到最后。

The time required for inserting a row is determined by the following factors, where the numbers indicate approximate proportions:插入行所需的时间由以下因素决定,其中数字表示近似比例:

This does not take into consideration the initial overhead to open tables, which is done once for each concurrently running query.这并没有考虑打开表的初始开销,对于每个并发运行的查询,打开表只需执行一次。

The size of the table slows down the insertion of indexes by log N, assuming B-tree indexes.假设是B树索引,表的大小会将索引的插入速度按logN降低。

You can use the following methods to speed up inserts:可以使用以下方法加快插入速度: