Difference between InnoDB and MyISAM? [duplicate]

2020-06-27 09:44发布


This question already has answers here:
Closed 9 years ago.

Possible Duplicate:
MyISAM versus InnoDB

Ok I read this information of Wikipedia and InnoDB seems better. Here is my question would it be OK to use InnoDB instead of MyISAM for selecting user data from the database? Or would it be better to stay with MyISAM for this.

And if I would to change to Inno would PDO still work with it and some old style query's?

$q = ("SELECT * ... );
$r = mysql_query($q);


  • InnoDB uses row locking, MyISAM uses table locking, therefore...
  • InnoDB is slower when it comes to SELECT
  • InnoDB enforces referential integrity (which is as very good thing)
  • InnoDB allows transactions


Generally I go with InnoDB if my table will have more updates/inserts/delete statements then select statements or I want relational database with foreign keys, if not I stick with MyISAM. If you go with InnoDB you will give up select statement performance and the ability to do full text search indexes.

The MyISAM storage engine.

The InnoDB storage engine.


My be worthwhile to consider whether you'll be using mostly SELECT queries or INSERT / UPDATE, since InnoDB supports row-level locking (better for insert / update), but MyISAM uses table-level locking (faster if you'll use just select). See this from ref manual for more info.


InnoDB vs. MyISAM won't have any difference with how you code your select statements. Where it will help is allow for foreign keys, which will help you keep referential integrity in your database, and if properly setup, help ensure not creating orphan records.

See http://en.wikipedia.org/wiki/Foreign_key for more information.


The biggest advantage of innodb over myisam is that innodb supports transactions/rollbacks. myisam will provide better performance overall, as it does not incur the same overhead. For a simple user table you might be best to stick with myisam.


It would be completely OK to use InnoDB instead of MyISAM for selecting user data,. PDO will work with it too and so will mysql_query and mysqli_query,. they have nothing to do with the table type.

But keep in mind that there are many different configurations that you need to understand before you start using it,. if you are a casual developer i suggest staying with MyISAM