博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL: Speed of INSERT Statements
阅读量:6156 次
发布时间:2019-06-21

本文共 1564 字,大约阅读时间需要 5 分钟。

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:

  • If you are inserting many rows from the same client at the same time, use statements with multiple VALUES lists to insert several rows at a time. This is considerably faster (many times faster in some cases) than using separate single-row statements. If you are adding data to a nonempty table, you can tune the variable to make data insertion even faster. See .

  • When loading a table from a text file, use . This is usually 20 times faster than using statements. See .

  • Take advantage of the fact that columns have default values. Insert values explicitly only when the value to be inserted differs from the default. This reduces the parsing that MySQL must do and improves the insert speed.

  • See for tips specific to MyISAM tables.

 

REF:

转载地址:http://jsifa.baihongyu.com/

你可能感兴趣的文章
js中document.write()使用方法
查看>>
随机生成50个字段的elasticsearch的测试程序输入
查看>>
如何使用流量精灵刷网站流量
查看>>
使用AutoMapper 处理DTO数据对象的转换
查看>>
java使用POI获取sheet、行数、列数
查看>>
js 调用 oc 的解释
查看>>
Linux学习笔记——Ubuntu更新软件源
查看>>
非nodejs方式的vue.js的使用
查看>>
普林斯顿公开课 算法2-2:选择排序
查看>>
SharePoint 2013 开启訪问请求
查看>>
jQuery(三) javascript跨域问题(JSONP解决)
查看>>
Redis和Memcached的区别
查看>>
ubuntu17.04 调试系统工具bcc,systamtap安装
查看>>
Spring+SpringMVC+MyBatis深入学习及搭建(二)——MyBatis原始Dao开发和mapper代理开发
查看>>
给初级拍摄者的十条好建议
查看>>
彻底搞清楚javascript中的require、import和export
查看>>
怎样一步步用D3画多曲线
查看>>
JAVA实现N皇后问题(回溯法)
查看>>
HDU 2689 Sort it【树状数组】
查看>>
周末,说声php的setter&getter(魔术)方法,你们辛苦了
查看>>