InnoDB or MyISAM?
I have two tables: Users and Friendships. The actions I have in the website are:
- Register
- Log in
- Select friends/people from users table
- Add people开发者_C百科 as friends
There are a little more actions but in general i wanted to know :
The Question:
Should I use InnoDB or MyISAM for the tables ? ( Or InnoDB for one and MyISAM for the other ? )
Always use InnoDB unless you specifically want to include a FULLTEXT
index on a particular table. Only InnoDB enforces foreign keys, and the more referential integrity you can build into the database the better off everyone's going to be.
Use InnoDB. You get foreign key constraints, transactions (so you can insert into two tables and either they both get committed or neither, so you aren't left with inconsistent information).
However, there is another big advantage. InnoDB supports MVCC (multi-versioning concurrency). This means that, while a transaction is operating on a row, other transactions/statements can see the old value of the row. With MyISAM that operation would block. Less blocking means you can have more users operating concurrently on your data set.
精彩评论