温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么进行mysql的sync_binlog参数实验

发布时间:2021-11-16 15:51:31 来源:亿速云 阅读:606 作者:柒染 栏目:MySQL数据库

今天就跟大家聊聊有关怎么进行mysql的sync_binlog参数实验,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

mysql sync_binlog参数实验
1,默认参数为1,即每次提交MySQL将进行一次fsync之类的磁盘同步指令来将binlog_cache中的数据强制写入磁盘
mysql> show variables like '%sync_binlog%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sync_binlog   | 1     |
+---------------+-------+
1 row in set (0.01 sec)


mysql> 
mysql> 


2,实验环境搭建
清除测试表t
mysql> truncate t;
Query OK, 0 rows affected (0.02 sec)


mysql> 
创建一个存储过程p1,往t表中进行五千次的插入,每次插入都提交
mysql> DELIMITER //  
mysql> CREATE PROCEDURE p1()
    -> begin
    ->  declare i int;
    ->  set i=0;
    ->  while i<5000 do
    ->     insert into t values(i);
    ->     set i=i+1;
    ->     commit;
    ->  end while;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)


mysql> 
mysql> 
3,当sync_binlog=1时,p1执行14.04秒
mysql> 
mysql> call p1;
Query OK, 0 rows affected (14.04 sec)


mysql> 
mysql> 


4,当sync_binlog=0时,p1执行6.94秒
mysql> set global  sync_binlog=0;
Query OK, 0 rows affected (0.00 sec)


mysql> 
mysql> truncate t;
Query OK, 0 rows affected (0.02 sec)


mysql> call p1;
Query OK, 0 rows affected (6.94 sec)


5,当sync_binlog=5时,p1执行8.28秒
mysql> set global  sync_binlog=5;
Query OK, 0 rows affected (0.00 sec)


mysql> truncate t;
Query OK, 0 rows affected (0.02 sec)


mysql> call p1;
Query OK, 0 rows affected (8.28 sec)
mysql> 

看完上述内容,你们对怎么进行mysql的sync_binlog参数实验有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI