歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux MySQL Xfs 與ext3 速度測試

Linux MySQL Xfs 與ext3 速度測試

日期:2017/2/28 16:15:43   编辑:Linux教程

環境 RedHat 5.6 mysql 5.1.54
64G 內存 E7 系列cpu 4顆

使用xfs 的文件格式

存儲過程

delimiter //
create procedure insert_mang_rows (in loops int) begin declare v1 int ; set v1=loops; while v1 >0 do
insert into test.test values(‘qwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww’,'wqqqqqqqqqqqqew’

,’weeeeeeeeeeeeeeeee’,'weeeeeeeeeeeeeeeee’);
set v1 = v1 – 1;
end while;
end;//

myisam 存儲引擎 使用存儲過程插入100w 行記錄

mysql> call insert_mang_rows(1000000);
Query OK, 1 row affected (20.10 sec)

使用innodb存儲引擎插入100w行、
innodb_flush_log_at_trx_commit 為默認值1
執行存儲過程 ,出去吃飯回來之後還沒有執行完畢,郁悶。

修改下面2個值後重啟mysql服務,執行存儲過程
innodb_flush_method=O_DIRECT
innodb_flush_log_at_trx_commit=0

mysql> call insert_mang_rows(1000000)//
Query OK, 1 row affected (38.51 sec)

修改下面2個值後重啟mysql服務,執行存儲過程
innodb_flush_method=O_DIRECT
innodb_flush_log_at_trx_commit=2

mysql> call insert_mang_rows(1000000)//
Query OK, 1 row affected (1 min 15.94 sec)

以上都是自動提交即,autocommit=1。

關閉自動提交

set autocommit=0;
innodb_flush_method=O_DIRECT
innodb_flush_log_at_trx_commit=2修改存儲過程

drop procedure if exists insert_mang_rows
delimiter //
create procedure insert_mang_rows (in loops int) begin declare v1 int ; set v1=loops; while v1 >0 do
insert into test.test values(‘qwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww’,'wqqqqqqqqqqqqew’

,’weeeeeeeeeeeeeeeee’,'weeeeeeeeeeeeeeeee’);
set v1 = v1 – 1;
end while;
commit ;
end;//

mysql> call insert_mang_rows(1000000)//
Query OK, 0 rows affected (27.50 sec)

以上是使用xfs 的系統格式,下面測試是使用ext3系統格式測試

ext3 格式 innodb 的引擎 和上面的配置是一樣測試

myisam 存儲引擎測試

myisam 的 ext3

mysql> call insert_mang_rows(1000000)//
Query OK, 1 row affected (27.12 sec)

還是比 innodb 的快,但是比xfs 的文件格式要慢

innodb_flush_log_at_trx_commit =2
innodb_flush_method=O_DIRECT
mysql> set autocommit=1//

mysql> call insert_mang_rows(1000000)//
Query OK, 1 row affected (1 min 19.51 sec)

設置不自動提交

mysql> set autocommit=1//

mysql> show variables like ‘auto%’;

+————————–+——-+
| Variable_name | Value |
+————————–+——-+
| auto_increment_increment | 1 |
| auto_increment_offset | 1 |
| autocommit | OFF |
| automatic_sp_privileges | ON |
+————————–+——-+
4 rows in set (0.00 sec)

mysql> call insert_mang_rows(1000000);
Query OK, 0 rows affected (38.81 sec)

經過上面測試可以看到 xfs 的文件格式比 ext3格式要快。關於innodb_flush_method=O_DIRECT
innodb_flush_log_at_trx_commit=2 參數設置請參考 http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html

Copyright © Linux教程網 All Rights Reserved