码迷,mamicode.com
首页 > 数据库 > 详细

MySQL: Speed of INSERT Statements

时间:2015-06-20 17:01:20      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

Speed of INSERT Statements

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:

  • Connecting: (3)

  • Sending query to server: (2)

  • Parsing query: (2)

  • Inserting row: (1 × size of row)

  • Inserting indexes: (1 × number of indexes)

  • Closing: (1)

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.

You can use the following methods to speed up inserts:

 

REF:

http://dev.mysql.com/doc/refman/5.0/en/insert-speed.html

http://dev.mysql.com/doc/refman/5.0/en/update-speed.html

MySQL: Speed of INSERT Statements

标签:

原文地址:http://www.cnblogs.com/emanlee/p/4590663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!