MyISAM versus InnoDB

Ovid on 2006-12-12T09:48:42

As seen here:

A general guideline could be as follows: if you require multi-statement transactions, advanced isolation levels and row-level locking, foreign key constraints, or otherwise have a requirement for ACID features, go for InnoDB. Otherwise, simply use MyISAM, the default.

I think I can restate that just a little clearer: don't use MyISAM.

Less dogmatically, unless you know exactly why you need MyISAM and you have the data to prove that this is what you need, don't use it. Period. And I want to see the data first. And how you collected it. And whether it was in a real-world environment. And I want to know what problem you're trying to solve and why the broken technology of MyISAM is the best choice. There are legitimate uses for MyISAM, but not many.


heh

Alias on 2006-12-12T12:40:10

> There are legitimate uses for MyISAM, but not many.

Like maybe a counter script, or some sort of simple log table, which about the most sophisticated things I've ever used it for.

Re:heh

Abigail on 2006-12-12T13:30:10

No, not even a counter script. Remember, MyISAM doesn't give you transactions, and for a counter script, you generally want to do:

    update counter set value = value + 1
    select value from counter
and you want to do that atomically.

Without transactions, why even bother having a database server?

Re:heh (Counter script)

Corion on 2006-12-12T15:03:36

Of course, for a counter you want to do

insert ip into counter
:-), and for querying it then

select count(*) from counter
... Now, if that's actually better than just an atomic append of a(ny) line to a text file remains to be discussed ...

Re:heh (Counter script)

Abigail on 2006-12-12T16:33:11

Yes, but you still want to wrap those statements into a single transaction.

Re:heh

Dom2 on 2006-12-12T13:34:52

As far as I know (I don't use MySQL) the only reason is full text search.

-Dom

Re:heh

Ovid on 2006-12-12T14:19:51

As far as I know (I don't use MySQL) the only reason is full text search.

If it was primarily a read-only server with heavy usage and only being written to in an extremely controlled manner, MyISAM might be a reasonable choice if you can't get performance any other way (short of paying for Oracle).

Re:heh

mpeters on 2006-12-12T17:29:11

If it was primarily a read-only server with heavy usage and only being written to in an extremely controlled manner

We use MyISAM for a dimensional data warehouse. The data in the warehouse is extracted from other databases (which are InnoDB) and are used by clients and software mostly to make complicated reports that just wouldn't be feasible on the normalized InnoDB tables. Since we already know the data is good we just want fast access to the extracted parts.

Re:heh

chromatic on 2006-12-12T18:57:09

A lot of people have never realized that this was MySQL's target task for many, many years.

Re:heh

Ovid on 2006-12-12T19:23:24

I initially laughed my head off at that because I thought you were talking about using MySQL to support broken Web counters :)

Re:heh

chromatic on 2006-12-12T20:33:28

That's PHP and MySQL, actually, but I don't blame either.

Re:heh

DAxelrod on 2006-12-14T20:26:45

Nor should we blame them, lest Perl and Sendmail are blamed for buggy form-to-mail scripts. :)

Be Warned

jk2addict on 2006-12-12T13:55:09

Just choosing one over the other because of transactions is a dangerous game. They don't store the same, and they don't perform the same; even on the same non-transactional queries in some circumstances (count(*), multiple PKs, etc). For that matter, don't just assume your schema should be the same if you plan on using one vs. the other.

This has always been a decent document to remind me that 'inno has transactions' isn't the only issue to think about:

http://jpipes.com/presentations/mysql_perf_tuning.pdf

Re:Be Warned

jk2addict on 2006-12-12T13:57:04

Oops. Forgot the other link:

http://jpipes.com/presentations/maximum_velocity_mysql.pdf

Re:Be Warned

Abigail on 2006-12-12T14:29:50

Oh, agree that 'inno has transactions' isn't the only thing to think about. The fact that Inno has transaction in itself isn't a reason to choice Inno.

However, the reverse is true. The fact that MyISAM doesn't have transactions is almost always reason enough to not use MyISAM. The fact that it's hard to come up with a case where you can get away with MyISAM is (for me) reason enought to not even consider.

Re:Be Warned

Ovid on 2006-12-12T15:08:54

That's a good point. No one would choose a car merely because it had a steering wheel and column, but you wouldn't even think about buying one without them.

Re:Be Warned

jk2addict on 2006-12-12T16:16:00

I don't disagree with anything said so far. It's just that whenever people post about Inno vs. MyISAM, I always like to post those links about the hardcore differences....hopefully so future readers will learn from my mistakes and pains of the past. :-)

Hot backups

acme on 2006-12-12T14:33:44

Well the one thing that sticks out is that you can't make hot backups of InnoDB without shelling out $500 per server per year. Pesky commercial software!

Re:Hot backups

merlyn on 2006-12-14T00:47:34

Even more reason to ignore MySQL and move to PostgreSQL, where you can make hot backups for free.

Re:Hot backups

acme on 2006-12-14T08:05:07

Hey, if you're going to be aggressive: at least MySQL has realised that people actually scale databases and that replication might be a good idea and so built it into the server ;-)

Re:Hot backups

Abigail on 2006-12-14T08:20:56

Now, if only MySQL had a more useful replication than replication of statements.

Re:Hot backups

acme on 2006-12-14T14:03:27

5.1 has row-based replication at least.

Re:Hot backups

merlyn on 2006-12-16T06:41:14

And the PostgreSQL team realized that by NOT building it into the distro, they would encourage competing implementations, and in fact, that's what's happened: both free and commercial implementations for free, all of which (I understand) are BETTER than what MySQL has built in.

MyISAM

Qiang on 2006-12-12T17:44:18

craigslist runs on MyISAM. http://radar.oreilly.com/archives/2006/04/database_war_stories_5_craigsl.html