MySQL multiple insert performance(MySQL 多次插入性能)
问题描述
我的数据包含大约 30 000 条记录.我需要将这些数据插入到 MySQL 表中.我将这些数据按 1000 分组并创建多个插入,如下所示:
I have data containing about 30 000 records. And I need to insert this data into MySQL table. I group this data in packages by 1000 and create multiple inserts like this:
INSERT INTO `table_name` VALUES (data1), (data2), ..., (data1000);
如何优化此插入的性能?我可以每次插入超过 1000 条记录吗?每行包含大小约为 1KB 的数据.谢谢.
How can I optimize performance of this inserting? Can I insert more than 1000 records per time? Each row contains data with size about 1KB. Thanks.
推荐答案
需要检查mysql服务器配置,具体检查缓冲区大小等
You need to check mysql server configurations and specifically check buffer size etc.
您可以从表中删除索引(如果有),以使其更快.一旦有数据就创建索引.
You can remove indexes from the table, if any, to make it faster. Create the indexes onces data is in.
看这里,你应该得到你需要的一切.
Look here, you should get all you need.
http://dev.mysql.com/doc/refman/5.0/en/insert-speed.html
它说,一个具有多个值的插入语句比多个插入语句快得多.
One insert statement with multiple values, it says, is much faster than multiple insert statements.
这篇关于MySQL 多次插入性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 多次插入性能
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 无法解决整理冲突 2021-01-01
