版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wyongqing/article/details/84405136
网上观点
网上大部分人在考虑如何选择MyISAM与InnoDB的依据是
-
innodb 支持事务、行级锁. 适合写多读少
-
myisam 表锁,适合读多写少
实际测试下查询速度
1千万(InnoDB)
select * 21秒
select id=xxx 0.026秒
count(id) 15.71秒(第一次16.71,第二次0秒,插入一条后16.476秒)
count(username) 16.956秒
avg(id) 18.41秒
1千万(Myisam)
select * 8.389秒
select id=xxx 0秒
count(*) 0秒
count(username) 1.643秒
avg(id) 3.793秒
myisam-->innodb 52.200秒
确实MyISAM比InnoDB快了3倍
可问题是实际中都是通过索引分批取数据,有谁有一次取那么多的数据呢? 而分批取数据性能都差不多。
存储引擎特性对比
下面是官方网站上mysql8.0的特性。可以看出MyISAM特性,InooDB都有,没有必须选择MyISAM的理由
| Feature | MyISAM | InnoDB |
| B-tree indexes | Yes | Yes |
| Backup/point-in-time 恢复 | Yes | Yes |
| Cluster database support | No | No |
| Clustered indexes | No | Yes |
| Compressed data | Yes (note 2) | Yes |
| Data caches | No | Yes |
| Encrypted data (note 3) | Yes | Yes |
| Foreign key support | No | Yes |
| Full-text search indexes | Yes | Yes (note 5) |
| Geospatial data type support | Yes | Yes |
| Geospatial indexing support | Yes | Yes (note 6) |
| Hash indexes | No | No (note 7) |
| Index caches | Yes | Yes |
| Locking granularity | Table | Row |
| MVCC | No | Yes |
| Replication support (note 1) | Yes | Yes |
| Storage limits | 256TB | 64TB |
| T-tree indexes | No | No |
| Transactions | No | Yes |
| Update statistics for data dictionary Yes Yes
官方网站怎么说MyISAM?
#原文
MyISAM: These tables have a small footprint. Table-level locking limits the performance in read/write workloads,
so it is often used in read-only or read-mostly workloads in Web and data warehousing configurations.
#意思
MyISAM应用范围较小。它是表级锁,对并发读写有限制。适合只读或者大部分是读的web应用或者配置性的数据仓库。
数据损坏
InnoDB会自动恢复,MyISAM需要定时检查
我的结论
-
从查询速度上,实际中是分批取数查询数据差不多
-
从特性上,InooDB是MyISAM的超集
-
从功能上,InooDB功能更强
所以网上说读多写少选择MyISAM是人云亦云。当然存在肯定有理由,为了兼容性,还是什么?
此生必看的科学实验-水知道答案
http://v.youku.com/v_show/id_XMjgzMzcwNDk4OA
《了凡四训》详解之改过之法
https://v.youku.com/v_show/id_XMzY5NTcxMDIwO
印光大师十念法(胡小林主讲第1集)
http://v.youku.com/v_show/id_XMzUwMzc4NzY4NA
精神病为什么治不好
https://v.qq.com/x/page/h0359zvupc0.html
百病之源
https://v.qq.com/x/page/o0359x7oy11.html