我是否正确,InnoDb比MyISAM更适合频繁并发更新和插入? [英] Am I right that InnoDb is better for frequent concurrent updates and inserts than MyISAM?

查看:401
本文介绍了我是否正确,InnoDb比MyISAM更适合频繁并发更新和插入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个网站,每天有数百名访问者,每天有成千上万的查询. 因此,数据库中的某些表很少更新,有些表每分钟更新几次,而有些表则每秒更新约10次.
MyISAM使用表级锁定进行更新,而InnoDb使用行级锁定.
因此,据我所知,对于具有频繁并发更新(每秒多次更新)的表,最好将它们设置为InnoDb,对于其他表(当然,如果我们不需要事务和外键,则更好) )可以使用MyISAM引擎.
我的想法对吗?

We have a websites with hundreds of visitors every day and tens of thousands queries a day. So, some tables in the database are updated very rarely, some tables are updated few times a minute and some tables are updated ~10 times a seconds.
MyISAM uses table-level locking for updates and InnoDb uses row-level locking.
So, as I understand, for tables with frequent concurrent updates (several updates per second) it is better to make them InnoDb, and for other tables (if we don't need transactions and foreign keys of course) it is ok to be with MyISAM engine.
Am I right in my thoughts?

推荐答案

MyISAM的读写速度更快,但不能同时.换句话说,如果您需要进行大量写操作,则速度会更快,但是如果您还希望人们同时阅读,则读者和作家之间会互相阻碍,您可能会遇到并发问题.您应该在这种情况下使用InnoDB,并且大多数mysql专家还是建议默认使用InnoDB,因为尽管在某些情况下使用InnoDB的速度较慢,但​​它通常被认为比MyISAM更可靠.

MyISAM is faster for reads and writes, but not at the same time. In other words, if you need to do a lot of writes, it will be faster, but if you want to also have people reading at the same time the readers and the writers will block each other and you may have concurrency issues. You should use InnoDB in such scenarios, and most mysql gurus recommend using InnoDB by default anyway because it's considered more generally reliable than MyISAM, despite being slower under some use cases.

这篇关于我是否正确,InnoDb比MyISAM更适合频繁并发更新和插入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆