原文地址:http://acmeextension.com/difference-between-innodb-and-myisam/

MyISAM and InnoDB are the most commonly used storage engine in MySQL whereas both storage engine types have advantages and disadvantages depending on the specific application.

However, MyISAM is the default storage engine chosen by MySQL database, when creating a new table. The major differences between MyISAM and InnoDB storage engines are :

1. Referential Integrity

Referential integrity ensures that relationships between tables remain consistent.
Or more specifically, this means when a table has a foreign key pointing to a different table. When an update or delete is made to the pointed-to-table then the changes will cascade to the linking table.

Suppose that we have two tables – Books and category. Books have a foreign key(say category_id) pointing to the Category table. In our example, if a Category is renamed, the linking table?s foreign keys will also update. if a category is deleted from the Category table, any books which point to the deleted entry will also be deleted. Furthermore, any new book must have that foreign key pointing to a valid, existing entry.

InnoDB is a relational DBMS (RDBMS) and thus has referential integrity, while MyISAM does not. So InnoDB supports foreign keys and referential integrity, including cascaded deletes and updates.

2. Transactions & Atomicity

Data in a table is managed using Data Manipulation Language (DML) statements, such as SELECT, INSERT, UPDATE and DELETE. A transaction group two or more DML statements together into a single unit of work, so either the entire unit is applied, or none of it is.

MyISAM does not support transactions whereas InnoDB does.

So if a table is using MyISAM engine and operation is interrupted, the operation is aborted immediately, and the rows (or even data within each row) that are affected remains affected, even if the operation did not go to completion.

So if a table is using InnoDB engine and operation is interrupted, because it using transactions, which has atomicity, any transaction which did not go to completion will not take effect, since no commit is made.

When you run an operation in MyISAM, the changes are set and you cannot roll back the changes while in InnoDB, those changes can be rolled back.

InnoDB provides auto-recovery after a crash of the MySQL server or the host on which the server runs.

3. Table-locking vs Row-locking

When a query runs against a MyISAM table, the entire table in which it is querying will be locked. This means subsequent queries will only be executed after the current one is finished. If you are reading a large table, and/or there are frequent read and write operations, this can mean a huge backlog of queries.

When a query runs against an InnoDB table, only the row(s) which are involved are locked, the rest of the table remains available for the other operations. This means queries can run simultaneously on the same table, provided they do not use the same row.

4. Reliability

MyISAM offers no data integrity – Hardware failures, unclean shutdowns and cancelled operations can cause the data to become corrupt. This would require full repair or rebuilds of the indexes and tables.

InnoDB, on the other hand, uses a transactional log, a double-write buffer and automatic checksumming and validation to prevent corruption. Before InnoDB makes any changes, it records the data before the transactions into a system tablespace file called ibdata1. If there is a crash, InnoDB would auto-recover through the replay of those logs.

5. FULLTEXT Indexing

InnoDB does not support FULLTEXT indexing until MySQL version 5.6.4. As of the writing of this post, many shared hosting providers? MySQL version is still below 5.6.4, which means FULLTEXT indexing is not supported for InnoDB tables.

However, this is not a valid reason to use MyISAM. It?s best to change to a hosting provider that supports up-to-date versions of MySQL. Not that a MyISAM table that uses FULLTEXT indexing cannot be converted to an InnoDB table.

6. Caching

InnoDB requires a lot of memory (buffer pool). The data and indexes are cached in memory. Changes are written to the log buffer (physical memory) and are flushed every second to the log files (method depends on innodb_flush_log_at_trx_commit value). Having the data in memory is a huge performance boost. MyISAM only caches indexes (key_buffer_size) so that's where you would allocate most of your memory if you're only using MyISAM.

Conclusion

In conclusion, InnoDB should be your default storage engine of choice. Choose MyISAM or other data types when they serve a specific need.

转载于:https://www.cnblogs.com/leodaxin/p/9554677.html

Difference Between InnoDb and MyISAM(个人觉着是好文章,简单易懂,推荐看)相关推荐

  1. 一句话说清聚集索引和非聚集索引以及MySQL的InnoDB和MyISAM

    聚集索引和非聚集索引以及MySQL的InnoDB和MyISAM经常遇到有人向我咨询这个问题,其实呢,网上帖子很多,也说的都对,但是呢,看客可不一定是真的理解了.所以今天在这里用最简短的语言让你明白这些 ...

  2. InnoDB与Myisam比较

    InnoDB与Myisam比较                                                                                     ...

  3. MySQL常见的三种存储引擎(InnoDB、MyISAM、MEMORY)

    MySQL是我们经常使用的数据库处理系统(DBMS),不知小伙伴们有没有注意过其中的"存储引擎"(storage_engine)呢?有时候面试题中也会问道MySQL几种常用的存储引 ...

  4. InnoDB与MyISAM对比

    2019独角兽企业重金招聘Python工程师标准>>> InnoDB和MyISAM是许多人在使用MySQL时最常用的两个表类型,这两个表类型各有优劣,视具体应用而定.基本的差别为:M ...

  5. innodb和myisam

    2019独角兽企业重金招聘Python工程师标准>>> 学习innodb和myisam两个数据表引擎的不同. 首先innodb采用b+tree数据结构myisam采用b-tree数据 ...

  6. 数据库使用--MySQL: InnoDB 还是 MyISAM?

    MyISAM存储引擎 MyISAM是 默认存储引擎.它基于更老的ISAM代码,但有很多有用的扩展.MyISAM存储引擎的一些特征: ·      所有数据值先存储低字节.这使得数据机和操作系统分离.二 ...

  7. InnoDB和MyISAM的区别与选择

    MyISAM 性能(适合小项目,读快速)MyISAM 是MySQL中默认的存储引擎,比如适合新闻系统,读为主. InnoDB 事务或外键支持(适合大项目,高并发读写)活跃用户20多万时候,也能很轻松应 ...

  8. innodb和myisam的区别

    innodb和myisam的区别: (1)事务处理: MyISAM是非事务安全型的,而InnoDB是事务安全型的(支持事务处理等高级处理): (2)锁机制不同: MyISAM是表级锁,而InnoDB是 ...

  9. mysql 内存引擎_MySQL常见的三种存储引擎(InnoDB、MyISAM、MEMORY)

    MySQL是我们经常使用的数据库处理系统(DBMS),不知小伙伴们有没有注意过其中的"存储引擎"(storage_engine)呢?有时候面试题中也会问道MySQL几种常用的存储引 ...

最新文章

  1. Go 语言 XML处理
  2. js MediaSource h264
  3. python实现并发http_python 2.7 如何实现http post多并发?
  4. CodeForces1082G Petya and Graph 最小割
  5. CNCF 官方大使张磊:Kubernetes 是一个“数据库”吗?
  6. [css] 异步加载CSS的方式有哪些?
  7. Visual Studio “类视图”和“对象浏览器”图标
  8. 助AI研究社群发出内建18种预先训练模型工具
  9. 云图说|初识ModelArts开发者生态社区——AI Gallery
  10. mysql 表2符合表1,MySQL:表tbl_2_1_15已满
  11. 异步下载图片+图片缓存
  12. 孙玄:基于CAP模型设计企业级真正高可用的分布式锁
  13. 2014年视频聊天室开发经验分享
  14. UE4 关闭屏幕显示信息响应
  15. 笔记本电脑开机指示灯亮但显示屏没有反应(已解决)
  16. 固定资产条码管理系统软件如何来管控制造家具行业资产?
  17. 业务层战略制定的思路和方法_如何科学的制定企业战略目标?(附流程与方法解析)...
  18. 自动化测试 selenium 模块 webdriver使用02
  19. 上海伯俊软件测试笔试题,【上海伯俊软件面试|面试题】-看准网
  20. springboot运行出现 错误: 找不到或无法加载主类 com.xxxx.xxxx.Application

热门文章

  1. 两款爱不释手的markdown编辑工具
  2. 使用redis的zset实现排行榜
  3. redis的info指令详解
  4. TomCat服务器和Web应用
  5. Oracle buffer状态深入剖析
  6. 【转】vi编辑器中如何复制粘贴文本
  7. 服务器2012怎么换桌面背景,2012年职称计算机Windows XP:更改桌面背景和颜色
  8. java七大_Java 7七大新功能
  9. java 命令 乱码_解决java 命令行乱码的问题
  10. 运维不懂这些面试题拿不到高薪