简体   繁体   English

MySQL - InnoDB与MyISAM

[英]MySQL - InnoDB vs MyISAM

I read the following article yesterday ( http://blogs.sitepoint.com/2010/11/19/mysql-mistakes-php-developers/ ) and it wrote the following: 我昨天阅读了以下文章( http://blogs.sitepoint.com/2010/11/19/mysql-mistakes-php-developers/ ),它写了以下内容:

MySQL has a number of database engines but you're most likely to encounter MyISAM and InnoDB. MySQL有许多数据库引擎,但你最有可能遇到MyISAM和InnoDB。

MyISAM is used by default. 默认情况下使用MyISAM。 However, unless you're creating a very simple or experimental database, it's almost certainly the wrong choice! 但是,除非您创建一个非常简单或实验性的数据库,否则几乎肯定是错误的选择! MyISAM doesn't support foreign key constraints or transactions which are essential for data integrity. MyISAM不支持对数据完整性至关重要的外键约束或事务。 In addition, the whole table is locked whenever a record is inserted or updated: it causes a detrimental effect on performance as usage grows. 此外,无论何时插入或更新记录,整个表都会被锁定:随着使用量的增加,它会对性能产生不利影响。

The solution is simple: use InnoDB. 解决方案很简单:使用InnoDB。

I've always used MyISAM because it was the default. 我一直使用MyISAM,因为它是默认的。 What do you think? 你怎么看?

If I were to upgrade to InnoDB, in phpMyAdmin, can I just edit each table and change it to innoDB or is there a more complex process to perform? 如果我要升级到InnoDB,在phpMyAdmin中,我可以编辑每个表并将其更改为innoDB,还是要执行更复杂的过程?

Thanks! 谢谢!

Yes, you can swap in and out engines like used underwear, if you like, without much trouble. 是的,如果你愿意,你可以交换进出内衣等引擎,没有太多麻烦。 Just change it in phpmyadmin. 只需在phpmyadmin中更改它。

But I wouldn't change it for the sake of changing it. 但我不会为了改变它而改变它。 Do you need to use foreign keys? 你需要使用外键吗? Change it. 更改。 Do you need row-level-locking instead of table-locking? 您是否需要行级锁定而不是表锁定? Change it. 更改。

It's worth noting that there are good reasons to use MyISAM, too. 值得注意的是,使用MyISAM也有充分的理由。 Take a look at FULLTEXT indexing. 看看FULLTEXT索引。 You can't do that with InnoDB. 你不能用InnoDB做到这一点。

UPDATE UPDATE

As of MySQL 5.6 FULLTEXT has been implemented for InnoDB tables as well. 从MySQL 5.6开始,FULLTEXT也已经为InnoDB表实现了。 Here is the manual . 这是手册

Sorry for bumping an old question, but this also helped me a lot to choose which engine, especially since MyISAM is faster for reads and my database tables had more read the write: 很抱歉碰到一个老问题,但这也帮助我选择了哪个引擎,特别是因为MyISAM的读取速度更快,而且我的数据库表有更多的读取内容:

http://www.rackspace.com/knowledge_center/article/mysql-engines-myisam-vs-innodb http://www.rackspace.com/knowledge_center/article/mysql-engines-myisam-vs-innodb

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

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