innodb_flush_log_at_trx_commit参数性能测试是怎样的,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
mysql> create table test_load(a int,b char(80)) engine=innodb;
Query OK, 0 rows affected (0.19 sec)
mysql> delimiter //
mysql> create procedure p_load(count int unsigned)
-> begin
-> declare s int unsigned default 1;
-> declare c char(80) default repeat('a',80);
-> while s <= count do
-> insert into test_load select null,c;
-> commit;
-> set s = s + 1;
-> end while;
-> end;
-> //
mysql> delimiter ;
mysql> call p_load(50000);
Query OK, 0 rows affected (3.02 sec)
mysql> show variables like '%flush_log%';
+--------------------------------+-------+
| Variable_name | Value |
+--------------------------------+-------+
| innodb_flush_log_at_timeout | 1 |
| innodb_flush_log_at_trx_commit | 0 |
+--------------------------------+-------+
mysql> call p_load(500000);
Query OK, 0 rows affected, 3 warnings (28.43 sec)
mysql> select * from test_load limit 5;
+------+----------------------------------------------------------------------------------+
| a | b |
+------+----------------------------------------------------------------------------------+
| NULL | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
| NULL | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
| NULL | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
| NULL | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
| NULL | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
+------+----------------------------------------------------------------------------------+
5 rows in set (0.12 sec)
mysql> set global innodb_flush_log_at_trx_commit=1;
Query OK, 0 rows affected (0.00 sec)
mysql> call p_load(500000);
Query OK, 0 rows affected (27.54 sec)
mysql> show variables like '%flush_log%';
+--------------------------------+-------+
| Variable_name | Value |
+--------------------------------+-------+
| innodb_flush_log_at_timeout | 1 |
| innodb_flush_log_at_trx_commit | 1 |
+--------------------------------+-------+
2 rows in set (0.09 sec)
mysql> truncate table test_load;
Query OK, 0 rows affected (0.23 sec)
mysql> call p_load(500000);
Query OK, 0 rows affected (24.63 sec)
mysql> set global innodb_flush_log_at_trx_commit=2;
Query OK, 0 rows affected (0.30 sec)
mysql> truncate table test_load;
Query OK, 0 rows affected (1.06 sec)
mysql> call p_load(500000);
Query OK, 0 rows affected (27.69 sec)
看完上述内容,你们掌握innodb_flush_log_at_trx_commit参数性能测试是怎样的的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!