MyISAM is better for write-heavy tables because InnoDB has a full table lock on insert.

Wait… what?

Bullshit, thats backwards.

Thats what I thought. Then my DBA schooled me on two new feathers in my mysql wizards cap:
1.) if you’re very very careful, myisam supports concurrent inserts, which means you can write to a table like crazy without locking it
2.) innodb prior to 5.1.22 does not have a table lock on insert, but it does have a lock on generating the next entry for an auto_increment column, such that any insert into that table that needs a new auto incremented ID is stuck in line waiting for its turn. Which isn’t technically a table lock, but if most of your inserts are new records using that auto incremented column, its a similar result.

So if you combine the two corner cases of an app that almost only ever append-inserts and a particular version of mysql, the conventional wisdom on innodb vs. myisam completely inverts itself.

databases are hard

Leave a Reply