12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
mysql数据库 时间:2024-11-26 22:10:04
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
innodb_flush_log_at_trx_commit参数实验1,首先设置sync_binlog为0,mysql> set global sync_binlog=0;Query OK, 0 rows affected (0.00 sec)创建一个存储过程p1,往t表中进行五
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
innodb_flush_log_at_trx_commit参数实验
1,首先设置sync_binlog为0,
mysql> set global sync_binlog=0;
Query OK, 0 rows affected (0.00 sec)
创建一个存储过程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)
2,现在该参数为2,即日志缓存区写到文件,但不会刷到磁盘上
插入5000条数据,时间是3.56秒
mysql> show variables like '%innodb_flush_log_at_trx%';
+--------------------------------+-------+
| Variable_name | Value |
+--------------------------------+-------+
| innodb_flush_log_at_trx_commit | 2 |
+--------------------------------+-------+
1 row in set (0.01 sec)
mysql> truncate t;
Query OK, 0 rows affected (0.02 sec)
mysql> call p1;
Query OK, 0 rows affected (3.56 sec)
3,现在该参数设置为1,即每次提交,日志缓存区写到日志文件,并刷到磁盘上
插入5000条数据,时间是6.21秒
mysql> set global innodb_flush_log_at_trx_commit=1;
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 (6.21 sec)
4,现在参数设置为0,即日志缓存区每秒一次地写到日志文件,并刷到磁盘
但是事务提交的时候,不做任何操作。插入5000条数据3.18秒
mysql> set global innodb_flush_log_at_trx_commit=0;
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 (3.18 sec)
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19