mysql:insert插入数据过慢如何解决,设置innodb_flush_log_at_trx_commit为0就能解决
问题:
MY SQL insert 速度过慢
最近在用MySQL做存储,测试中发现插入数据太慢了,插入速度只有20-30 条/秒,后来查资料后,将MySQL的1个参数:innodb_flush_log_at_trx_commit,1改为了0(修改方法,可以直接修改my.ini(windows)/my.cnf(linux)中的对应参数,似乎用命令直接设置没有效果),插入速度就提升到了3000+每S,MySQL的文档中,对这个参数的描述如下:
If the value of innodb_flush_log_at_trx_commit is 0, the log buffer is written out to the log file once per second and the flush to disk operation is performed on the log file, but nothing is done at a transaction commit. When the value is 1 (the default),
the log buffer is written out to the log file at each transaction commit and the flush to disk operation is performed on the log file. When the value is 2, the log buffer is written out to the file at each commit, but the flush to disk operation is not performed
on it. However, the flushing on the log file takes place once per second also when the value is 2. Note that the once-per-second flushing is not 100% guaranteed to happen every second, due to process scheduling issues.
这样,如果transaction commit的频率非常高,1秒钟内会进行很多次的话,可以考虑将其设置为0,但这样就要承担数据库Crash后,1秒内未存储到数据库数据丢失可能的风险
设置后重启mysql,再重新执行存储过程,基本上插入速度能达到6000条/s。
mysql:insert插入数据过慢如何解决,设置innodb_flush_log_at_trx_commit为0就能解决的更多相关文章
- mysql insert插入时实现如果数据表中主键重复则更新,没有重复则插入的四种方法
[CSDN下载] Powerdesigner 设计主键code不能重复等问题 [CSDN博客] Oracle中用一个序列给两个表创建主键自增功能的后果 [CSDN博客] MySQL自增主键删除后重复问 ...
- MySQL之插入数据(添加数据)-INSERT
基本语法: INSERT 语句有两种语法形式,分别是 INSERT…VALUES 语句和 INSERT…SET 语句. 1.INSERT...VLAUES语句 INSERT VLAUES的语法格式如下 ...
- MySQL数据库插入数据出现 ERROR 1526 (HY000): Table has no partition for value xxx
MySQL数据库插入数据出现ERROR 1526 (HY000): Table has no partition for value xxx工作的时候发现无法插入数据,报错:ERROR 1526 (H ...
- Visual Studio 2017 - Windows应用程序打包成exe文件(2)- Advanced Installer 关于Newtonsoft.Json,LINQ to JSON的一个小demo mysql循环插入数据、生成随机数及CONCAT函数 .NET记录-获取外网IP以及判断该IP是属于网通还是电信 Guid的生成和数据修整(去除空格和小写字符)
Visual Studio 2017 - Windows应用程序打包成exe文件(2)- Advanced Installer Advanced Installer :Free for 30 da ...
- Python向mysql数据库插入数据
一.向表tcolor中插入数据的主要流程如下: import datetimeimport pymysql.cursorsconnection = pymysql.connect(host='loca ...
- phalcon: update修改数据却变成了insert插入数据
phalcon: 在对表进行操作是,update修改数据却变成了insert插入数据. 发现,update的时,无论怎么加where都会变成了insert插入数据. 检查了一下表,原来是表没有 主键引 ...
- MySQL大批量插入数据
MySQL大批量插入数据 1. 对于Myisam类型的表,可以通过以下方式快速的导入大量的数据. ALTER TABLE tblname DISABLE KEYS; loading the ...
- 快速解决设置Android 23.0以上版本对SD卡的读写权限无效的问题
快速解决设置Android 23.0以上版本对SD卡的读写权限无效的问题 转 https://www.jb51.net/article/144939.htm 今天小编就为大家分享一篇快速解决设置And ...
- Mysql常用sql语句(22)- insert 插入数据
测试必备的Mysql常用sql语句系列 https://www.cnblogs.com/poloyy/category/1683347.html 前言 终于讲完基础的查询语句了...这篇讲的就是插入数 ...
随机推荐
- 树状数组区间加法&区间求和操作
树状数组区间加法&区间求和操作 一般的树状数组解决区间加&单点询问并不复杂 但是要解决区间求和... 我们假设原数组是\(\{a_i\}\),差分数组\(\{d_i=a_i-a_{i- ...
- Mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server
这个问题是因为在数据库服务器中的mysql数据库中的user的表中没有权限(也可以说没有用户),下面将记录我遇到问题的过程及解决的方法. 在搭建完LNMP环境后用Navicate连接出错 遇到这个问题 ...
- 【linux】硬盘原理简介和分区
硬盘是计算机重要的一个部件,计算机中的数据都是保存在硬盘中,比如mysql的数据,linux系统日志及其他的应用日志,还有很多视频,音频,图片等文件都是保存在硬盘中,所以硬盘是计算机不可或缺的一个部件 ...
- sscanf、sprintf、stringstream常见用法
转载自:https://blog.csdn.net/jllongbell/article/details/79092891 前言: 以前没有接触过stringstream这个类的时候,常用的字符串和数 ...
- C语言中的类型转换——将字符串s转换为整数型(int)类型
在讲类型转换之前,我们先要理解下C语言中单引号和双引号的区别. 先讲双引号,双引号就是字符串,我们要证实我们的想法,我选择写一段代码看看开: #include <stdio.h> int ...
- configure: error: no acceptable C compiler found in $PATH 问题解决
解决办法: 安装GCC软件套件 [root@localhost ~]# yum install gccLoaded plugins: fastestmirrorLoading mirror speed ...
- JQuery未来元素事件监听写法
$(document).on('click','.div1',function(){ alert("abc"); }); 格式一致,第一个参数写事件,第二个参数给谁写事件(选择器) ...
- 小R的树(权限题)
解:考场上爆0了...... 回想怎么求两个排列的最长公共子序列. 回想怎么求1~n每个数恰出现两次的两个序列的最长公共子序列.就是每个数替换为它在另一个序列里的出现位置,降序. 所以我们可以把这每个 ...
- A1004. Counting Leaves
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family member ...
- MVC过滤器处理Session过期
一.自定义一个Action过滤器 public class CheckSession: ActionFilterAttribute { public override void OnActionExe ...