Reply
MyISAM vs InnoDB in MySQL
Old 06-20-2007, 02:00 AM MyISAM vs InnoDB in MySQL
mwsource's Avatar
Skilled Talker

Latest Blog Post:
No Away Message Required.
Posts: 57
Name: Reid
Location: Georgia, USA
So at this point I am at a total loss. Can someone with some experience please explain to me what the differences and/or advantages between MyISAM and InnoDB. I noticed this thread, however it really didn't give enough detail about why I should or should not use one over the other.

I have also heard that InnoDB is becoming increasingly used more in higher level web applications than the default MyISAM.

Any ideas?
__________________
Reid Workman - My Blog - Free Media Community - Try Freelancing for a living
mwsource is offline
Reply With Quote
View Public Profile Visit mwsource's homepage!
 
When You Register, These Ads Go Away!
Old 06-20-2007, 02:09 AM Re: MyISAM vs InnoDB in MySQL
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,024
Name: Forrest Croce
Location: Seattle, WA
http://dev.mysql.com/doc/refman/5.0/...e-engines.html

It depends what you'd like to do. MyISAM seems right for databases that don't change very often, that are there more to let you play with data using SQL queries. InnoDB is probably a better option when you need to make a lot of changes to your data, adding new rows and changing existing ones regularly. If you need to keep track of user settings or behavior, this is "transactional." In fact, all queries run in some type of implicit transaction if you don't create one explicitly.

Quote:
MySQL supports several storage engines that act as handlers for different table types. MySQL storage engines include both those that handle transaction-safe tables and those that handle non-transaction-safe tables:
  • MyISAM manages non-transactional tables. It provides high-speed storage and retrieval, as well as fulltext searching capabilities. MyISAM is supported in all MySQL configurations, and is the default storage engine unless you have configured MySQL to use a different one by default.
  • The MEMORY storage engine provides in-memory tables. The MERGE storage engine allows a collection of identical MyISAM tables to be handled as a single table. Like MyISAM, the MEMORY and MERGE storage engines handle non-transactional tables, and both are also included in MySQL by default.
    Note: The MEMORY storage engine formerly was known as the HEAP engine.
  • The InnoDB and BDB storage engines provide transaction-safe tables. InnoDB is included by default in all MySQL 5.0 binary distributions. In source distributions, you can enable or disable either engine by configuring MySQL as you like.
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 06-20-2007, 02:20 AM Re: MyISAM vs InnoDB in MySQL
mwsource's Avatar
Skilled Talker

Latest Blog Post:
No Away Message Required.
Posts: 57
Name: Reid
Location: Georgia, USA
Excellent explanation, I really do appreciate you dumbing it down for me. I have not really been too terribly involved in database architecture so I really don't completely understand somethings when it comes to database types and optimization.

I appreciate your response!
__________________
Reid Workman - My Blog - Free Media Community - Try Freelancing for a living
mwsource is offline
Reply With Quote
View Public Profile Visit mwsource's homepage!
 
Old 06-20-2007, 03:53 AM Re: MyISAM vs InnoDB in MySQL
Average Talker

Posts: 27
Name: Mike Robinson
Location: London, England
I agree - that was an excellent explanation but I'd say stick with the default (MyISAM). It works well for most applications and that's why it's the standard. If you then need want transactions in your database then use InnoDB.

A transaction is where you have a number of lines of SQL and, if any statement fails, then all the statements will fail together rather than the first statement working and the next failing. Transactions are used a lot in the financial world but aren't usually necessary in standard web apps. The downsides of transactions are increased complexity in the code and possible performance/locking issues.

I'd just stick with what MySQL gives you by default and forget that there are other engines available.

Mike
mike_bike_kite is offline
Reply With Quote
View Public Profile Visit mike_bike_kite's homepage!
 
Old 06-20-2007, 06:40 AM Re: MyISAM vs InnoDB in MySQL
Pathan's Avatar
Junior Talker

Posts: 2
Name: Sajid Iqbal
Yeah! MyISAM works great. InnoDB is not suitable for some well know scripts like PhplinksDirectory.
Pathan is offline
Reply With Quote
View Public Profile
 
Old 06-20-2007, 12:00 PM Re: MyISAM vs InnoDB in MySQL
Learning Newbie's Avatar
Moderator

Posts: 5,199
Name: John Alexander
Quote:
Originally Posted by mike_bike_kite View Post
A transaction is where you have a number of lines of SQL and, if any statement fails, then all the statements will fail together rather than the first statement working and the next failing. Transactions are used a lot in the financial world but aren't usually necessary in standard web apps. The downsides of transactions are increased complexity in the code and possible performance/locking issues.
You're right that most applications today just run on the defaults for their platform, and the people who write those platforms know it. I don't think transactions are limited to the finance world at all - I've never worked in finance and have had to deal with them pretty regularly.
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-20-2007, 07:03 PM Re: MyISAM vs InnoDB in MySQL
Average Talker

Posts: 27
Name: Mike Robinson
Location: London, England
MyISAM - is the default because it works great for just about every need. That's why it's the default.

Transactions - get used far more often than is really necessary and, as the number of transactions builds up, it leads to performance & locking issues.

As long as you put in a little defensive coding (usually around null and zero values) there shouldn't be many errors. Defensive coding should also allow an application to be able to restart just where it left off in the case of a power down etc - usually status tables etc help a great deal here.

I actually find it very difficult to get SQL to fail - In fact I can't remember any SQL code failing in the past 15 years (Sybase, SQL Server, Oracle or MySQL) - with the minor exceptions of power outages. Perhaps I've just been lucky!

Mike
mike_bike_kite is offline
Reply With Quote
View Public Profile Visit mike_bike_kite's homepage!
 
Old 06-21-2007, 01:13 AM Re: MyISAM vs InnoDB in MySQL
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,024
Name: Forrest Croce
Location: Seattle, WA
For the record, transactions are a mixed bag.

All interactions with the data store take place in a transaction; it can either be an implicit one, or an explicit one. If you cancel a delete or update query before it finishes executing, the work that's already been done is rolled back. The difference isn't whether transactions are being used, it's whether they span multiple commands.

Sometimes that's a good thing. If you have a series of five inserts, updates, and deletes, it can be more efficient for them to all happen in the scope of a single transaction than in five individual ones, but that depends on the db engine you're using, and the way it's used.

On the other hand, rolling back is more expensive than most operations. There's extra begin transaction and commit or rollback code that needs to happen when you create explicit transactions. You increase the risk of a deadlock, or just slower performance due to contention - several different transactions all lining up to take a lock on a particular row or even just a table. You can do a lot to mitigate the deadlock problem, but if you use an isolation level that demands locks, those are a bad thing to hold onto longer than necessary. Locks can escalate on their own when you use too many of them or the server comes under memory pressure. Basically, like Mike is suggesting, if you can write your application in a way that doesn't need transactions, you're probably better off.

Now that's all for the record ... for NW Source, if you don't have a specific reason in mind why you need to use explicit transactions, then you don't need them. If you find your app doing a lot of inserts, updates, and deletes, you might want to reconsider your options. But MySQL lets you assign a storage engine to individual tables, so you can change your mind later with a minimum of effort.
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Reply     « Reply to MyISAM vs InnoDB in MySQL
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.19563 seconds with 12 queries