views:

48

answers:

2

I have a table where I'm esentially only writing.

Think of it as a "transactions" list, where I keep all the details, and I also have a "total" stored in another table. That total is redundant, for performance, but it can be re-calculated if needed from this transactions table.

What is better from a performance point of view, keeping in mind that several people will be simultaneoulsy INSERTing (never UPDATEing) to this table, which is never ever read?

Should I use InnoDB, or MyISAM?

(I'm already having performance problems here, i'm not prematurely optimizing)

+2  A: 

Use the ARCHIVE storage method for this. It's made for precisely this kind of of write-many read-almost-never application.

Ollie Jones
Thank you for that idea! I didn't know about the Archive engine. Now, from that article, is seems that'll save disk space, but it won't be much faster than MyISAM, correct?
Daniel Magliola
ARCHIVE will be faster than myISAM for writing. But, if you have to read it, it will be quite slow because everything is a full table scan. Your explanation of the application indicates that you will read very rarely indeed, so this should be OK.
Ollie Jones
+1  A: 

Usually you would use MyISAM for tables that only ever grow. MyISAM also has the advantage of supporting MERGE tables, so you don't have to have just one enormous table.

But, if you are "never" going to read from it, why use a table at all? Just write directly to a file. I'm curious what your performance issues are. You might look into the Blackhole table type with replication. Blackhole on the master, MyISAM or Archive on the slave.

Brent Baisley
Thank you for your reply. I *might* want to read from it, and it's going to be **much** more convenient to do so from a structured table than a file should I ever need to. Of course, if having such a table is impractical, I can go to a file, but it doesn't seem like it should be, given the volume I'm managing.As for Blackhole, we are not doing replication yet, just one MySQL.
Daniel Magliola
The performance issue is that sometimes, the whole MySQL server freezes for several seconds, delaying ALL other requests, and going through the "slow query logs", this query seems to show up a lot, so it's looking suspicious, even though it should be reasonably innocent...
Daniel Magliola
Sounds like a deadlock?
Justice
Maybe, how would you diagnose it?
Daniel Magliola
deadlocks would only happen with InnoDB tables. MyISAM uses table locking and does not support transactions. While technically possible (UPDATE with JOIN), you should never see a deadlock with MyISAM.
Brent Baisley
I've used MyISAM table to "log" over a million records a day without problems. Not sure how much you are trying to log.
Brent Baisley