Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql中高效的多行插入_Mysql_Performance_Insert - Fatal编程技术网

mysql中高效的多行插入

mysql中高效的多行插入,mysql,performance,insert,Mysql,Performance,Insert,可能重复: 在阅读一本关于mysql的书时,我发现了两种在数据库中插入行的方法 Method 1 INSERT INTO tableName (col1, col2, col3) VALUES('a', 'b', 'c'); INSERT INTO tableName (col1, col2, col3) VALUES('d', 'b', 'c'); INSERT INTO tableName (col1, col2, col3) VALUES('e', 'b', 'c'); Metho

可能重复:

在阅读一本关于mysql的书时,我发现了两种在数据库中插入行的方法

Method 1 

INSERT INTO tableName (col1, col2, col3) VALUES('a', 'b', 'c');
INSERT INTO tableName (col1, col2, col3) VALUES('d', 'b', 'c');
INSERT INTO tableName (col1, col2, col3) VALUES('e', 'b', 'c');

Method 2

INSERT INTO tableName (col1, col2, col3) VALUES('a', 'b', 'c'), ('d', 'b', 'c'), ('e', 'b', 'c');

第二种方法比第一种更有效吗?或者它只是多次调用
方法1

第二种方法更有效


第一种方法在每次插入行时创建一个连接,第二种方法使用单个连接插入所有行。但是,有一个
max\u allowed\u数据包
限制了客户的
INSERT
语句的长度。

您能简单介绍一下max\u allowed\u数据包的大小吗?它是用户可配置的吗?@Prashantsigh topic解释了它控制的内容,topic解释了如何配置设置。