5 ms·
The MySQL MyISAM and InnoDB engines and a grocery checkout
There's plenty of discussions centered on the choice between the MySQL MyISAM and InnoDB engines. I've illustrated a case that has bitten me in the past.
- idlewords 17y agoThe analogy is helpful, but leaves some things out. In one of the grocery stores, you'll find that if the lights flicker off and for just a second, half the products on the shelves may end up unusable. And if your store gets past a certain size, a sinkhole may appear and suck most of your inventory underground with no warning. The only reason I can think of for using MyISAM tables in a web app is the terrible default InnoDB settings in MySQL. Users unfamiliar with InnoDB may not realize that the awful performance is an artifact of bad configuration, and easily fixed.
- bhseo 17y agoEven after you've spent days tweaking the performance, you are still left with a fundamentally slower engine.
- munctional 17y agoI'd rather have a consistent database than a fast one!
- towndrunk 17y agoCan you provide some info or a link on this config change. Thanks!
- modoc 17y agoI'm still not sure why folks still use MyISAM. I'm sure there may be some edge case where it makes more sense, but in generally InnoDB seems like a better choice (not just regarding row level locking). Or postgres:)
- DonnyK 17y agoI've yet to find a good comparison of the two. In fact, from what I've seen it seems better to use MyISAM when you don't need support for ACID transactions.
- idlewords 17y agoI don't agree. MyISAM tables are easy to trash, and the table locking on update can bite you. There's no real disadvantage to using InnoDB other than having to learn to tune it a litte bit, and your data will be much safer.
- chrisbolt 17y agoDefine 'easy to trash'. I've been using MyISAM without problems for years now.
- acl 17y agoI'm curious about this too -- I've used MyISAM for many projects without a problem.
- idlewords 17y agoThe two ways I've experienced: 1. Yank power cord while db writes are happening. 2. Grow the tables over a couple of GB in size.
- spudlyo 17y agoMyISAM is like the ext2 filesystem. You crash and you end up spending a long time doing an fsck, where you have to verify the consistency by walking all the data structures. InnoDB is more like ext3, where you can make things consistent by replaying the changes in the journal. Doing repair on a large MyISAM table can take hours and hours.
- AdamN 17y agoMan this is annoying: 1. The MyISAM/InnoDB debate is so stale it stinks. If you're using MySQL, you should be using InnoDB unless you know exactly why you should use MyISAM. None of these issues are relevant until you have alot of concurrency and uptime/transactions/integrity are radically more important than potentially faster SELECT statements on MyISAM. 2. Did HN really just put this flaccid article to the top of the list? Aren't we more technical than this?
- spudlyo 17y agoI'd vote it down if I could, it's far too fluffy and short for my tastes. The only reason I could think of using MyISAM is if you need features that only it supports, like compression, MRG_MyISAM tables, or full text search. Having said that, the newer InnoDB plugins support compression, with partitioning you don't need MRG_MyISAM, and you can use something like Sphinx for full text searching, which integrates nicely into MySQL.