手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

MySQL5.1 MyISAM与InnoDB 引擎读写性能对比

[日期:2014-01-05] 来源:Linux社区  作者:freeloda [字体:大 中 小]

五、500 万数据性能测试
1.t1表插入并查询数据
MySQL> insert into t1 select * from t1; 
Query OK, 5242880 rows affected (2.35 sec)   
Records: 5242880  Duplicates: 0  Warnings: 0
mysql> select count(*) from t1; 
+----------+   
| count(*) |   
+----------+   
| 10485760 |   
+----------+   
1 row in set (0.00 sec)

2.t2表插入并查询数据
mysql> insert into t2 select * from t2; 
ERROR 1206 (HY000): The total number of locks exceeds the lock table size

注,大家可以看到Innodb引擎插入500多万行数据直接报错。
原因:InnoDB表执行大批量数据的更新,插入,删除操作时会出现这个问题,需要调整InnoDB全局的innodb_buffer_pool_size的值来解决这个问题,并且重启mysql服务。
查看一下默认的innodb_buffer_pool_size默认为8M,
mysql> show variables like "innodb_buffer_pool_size"; 
+-------------------------+---------+   
| Variable_name          | Value  |   
+-------------------------+---------+   
| innodb_buffer_pool_size | 8388608 |   
+-------------------------+---------+   
1 row in set (0.00 sec)

下面我们修改一下并重启mysql,
[root@node6 ~]# vim /etc/my.cnf
innodb_buffer_pool_size = 384M
[root@node6 ~]# service mysqld restart 
Shutting down MySQL..... SUCCESS!   
Starting MySQL. SUCCESS!
mysql> show variables like "innodb_buffer_pool_size"; 
+-------------------------+-----------+   
| Variable_name          | Value    |   
+-------------------------+-----------+   
| innodb_buffer_pool_size | 402653184 |   
+-------------------------+-----------+   
1 row in set (0.00 sec)

好了,问题解决下面我们继续测试。
mysql> insert into t2 select * from t2; 
Query OK, 5242880 rows affected (52.81 sec)   
Records: 5242880  Duplicates: 0  Warnings: 0
mysql> select count(*) from t2; 
+----------+   
| count(*) |   
+----------+   
| 10485760 |   
+----------+   
1 row in set (6.63 sec)

3.总结
(1).MyISAM 引擎
插入500多万行数据花费的时间为2.35秒。

用select count(*) from t1 命令查询的时间为 0.00 秒。

(2).InnoDB 引擎
插入500多万行数据花费的时间为 52.81 秒。

用select count(*) from t1 命令查询的时间为 6.63 秒。

六、 1000 万数据性能测试
1.t1表插入并查询数据
mysql> insert into t1 select * from t1; 
Query OK, 10485760 rows affected (8.47 sec)   
Records: 10485760  Duplicates: 0  Warnings: 0
mysql> select count(*) from t1; 
+----------+   
| count(*) |   
+----------+   
| 20971520 |   
+----------+   
1 row in set (0.07 sec)

2.t2表插入并查询数据
mysql> insert into t2 select * from t2; 
Query OK, 10485760 rows affected (1 min 53.02 sec)   
Records: 10485760  Duplicates: 0  Warnings: 0
mysql> select count(*) from t2; 
+----------+   
| count(*) |   
+----------+   
| 20971520 |   
+----------+   
1 row in set (18.50 sec)

3.总结
(1).MyISAM 引擎
插入1000多万行数据花费的时间为 8.47 秒。

用select count(*) from t1 命令查询的时间为 0.07 秒。

(2).InnoDB 引擎
插入1000多万行数据花费的时间为 53.02 秒。

用select count(*) from t1 命令查询的时间为 18.50 秒。

七、总结

MyISAM 引擎

数据(单位/万) 插入数据时间(单位/秒) 查看数据时间(单位/秒)
100 0.64 0.00
200 1.23 0.00
500 2.35 0.00
10000 8.47 0.07

 

InnoDB 引擎

数据(单位/万) 插入数据时间(单位/秒) 查看数据时间(单位/秒)
100 13.03 1.20
200 26.32 2.08
500 52.81 6.63
1000 53.02 18.50

注,从插入数据时间和查看数据时间这两个数据来看,可以说MyISAM引擎是完胜InnoDB引擎。好了,这次的博客就到这里了。最后,希望大家有所收获^_^……

linux
相关资讯       InnoDB  MyISAM 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款