简体   繁体   English

MyISAM和InnoDB表在一个数据库中

[英]MyISAM and InnoDB tables in one database

I have a database with about 30 tables and 5 tables of them is write-intensive. 我有一个包含大约30个表的数据库,其中5个表是写密集型的。

I'm considering 我在考虑

  1. Convert 5 write-intensive tables to use InnoDB engine and keep the rest on MyISAM engine 转换5个写密集型表以使用InnoDB引擎,并将其余部分保留在MyISAM引擎上

  2. Convert all tables to use InnoDB engine. 转换所有表以使用InnoDB引擎。

I wonder which approach is better? 我想知道哪种方法更好?

To be more specific 更加具体

The reason I want to keep some table on MyISAM engine is some of them has around 1,000,000 rows. 我想在MyISAM引擎上保留一些表的原因是它们中的一些有大约1,000,000行。 I'm not sure how slower it will be for queries like "SELECT COUNT(*)" on these tables after converted to InnoDB. 我不确定转换为InnoDB后这些表上的“SELECT COUNT(*)”查询会有多慢。

I haven't done a test. 我没有做过测试。 I prefer getting some advices from any of you before start the switch. 在开始转换之前,我更喜欢从你们这里得到一些建议。

These days, I always default to using InnoDB, especially on the write-intensive tables you mention where MyISAM suffers from full table locking. 这些天,我总是默认使用InnoDB,特别是在你提到的写密集表中,MyISAM遭受全表锁定。 Here's a to-the-point comparison. 这是一个比较点。

Reasons to use MyISAM: 使用MyISAM的原因:

  • Tables are really fast for select-heavy loads 对于选择重的负载,表格非常快
  • Table level locks limit their scalability for write intensive multi-user environments. 表级锁定限制了它们在写密集型多用户环境中的可伸缩性。
  • Smallest disk space consumption 最小的磁盘空间消耗
  • Fulltext index 全文索引
  • Merged and compressed tables. 合并和压缩表。

Reasons to use InnoDB: 使用InnoDB的原因:

  • ACID transactions ACID交易
  • Row level locking 行级锁定
  • Consistent reads – allows you to reach excellent read write concurrency. 一致的读取 - 允许您达到出色的读写并发性。
  • Primary key clustering – gives excellent performance in some cases. 主键聚类 - 在某些情况下可提供出色的性能。
  • Foreign key support. 外键支持。
  • Both index and data pages can be cached. 索引和数据页面都可以缓存。
  • Automatic crash recovery – in case MySQL shutdown was unclean InnoDB tables will still - recover to the consistent state- No check / repair like MyISAM may require. 自动崩溃恢复 - 如果MySQL关闭是不洁的InnoDB表仍将 - 恢复到一致状态 - 不像MyISAM那样需要检查/修复。
  • All updates have to pass through transactional engine in InnoDB, which often decreases - performance compared to non-transactional storage engines. 与非事务性存储引擎相比,所有更新都必须通过InnoDB中的事务引擎,这通常会降低性能。

The above was taken from this site , which no longer seems to be working. 以上内容取自该网站 ,似乎不再有效。

pros and cons for each. 每个人的利弊。

for (1) pros: less disk space usage, myisam much faster for read-heavy access patterns 对于(1)专业人士:更少的磁盘空间使用,myisam对于读取繁重的访问模式来说要快得多

cons: memory must be shared between the innodb buffers and myisam key buffers. 缺点:必须在innodb缓冲区和myisam密钥缓冲区之间共享内存。 innodb tables are about 4x bigger than their myisam counterparts. innodb表比他们的myisam表大约4倍。 programmatic code must be adapted for deadlock handling. 程序代码必须适应死锁处理。

just remember innodb will also lock if you're changing an indexed column or primary key. 请记住,如果您要更改索引列或主键,innodb也会锁定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM