InnoDB

From: THERE IS NO GOD BUT (RENDLE)12 Nov 2009 19:50
To: ALL1 of 34

So, got a table with 4.6m rows of test data. Engine set to InnoDB, running a self-join query on it takes about a minute and a half. Create a copy of the table using MyISAM. Same query takes a tenth of a second. I mean, I know InnoDB is all transactional and referential integrity and shit, but that's fucked up.

 

Right. Just for larks, I'm going to see how it performs with 50m rows.

From: 99% of gargoyles look like (MR_BASTARD)12 Nov 2009 20:31
To: THERE IS NO GOD BUT (RENDLE) 2 of 34
You rock, Tiger!
From: Peter (BOUGHTONP)12 Nov 2009 23:53
To: THERE IS NO GOD BUT (RENDLE) 3 of 34
Got correct indexes on the columns you're joining with?

Generate the Query Execution Plan and see what it's trying to do (shove "EXPLAIN EXTENDED" in front of the select statement).
From: THERE IS NO GOD BUT (RENDLE)13 Nov 2009 00:15
To: Peter (BOUGHTONP) 4 of 34
I think it's the COUNT(*) that's fucking it up.

I'm just bundling a PostgreSQL 8.4 instance that is almost certainly going to have the same problem.

From what I've read, MyISAM is the best bet for read-intensive applications, which this is. And most of the data operations are going to be inserts, with a small number of deletes and no updates at all. But I'll finish my testing anyway, because I am Diligent Man™
From: DSLPete (THE_TGG)16 Nov 2009 09:54
To: THERE IS NO GOD BUT (RENDLE) 5 of 34

COUNT(*) takes ages for InnoDB tables as it actually counts the rows individually when you do it. MyISAM on the other hand keeps an internal counter, which means count(*) is fast, but introduces other problems of its own later on.

 

When you are volume testing these 2, make sure you try selects/inserts/updates concurrently as MyISAM can (does) have big scaling problems caused by the fact it uses table level locking in some fairly trivial situations, so while individual queries can seem fast in isolation when you introduce other operations you get deadlock hell.

 

If it helps, as a base rule, you should be using InnoDB unless you know you need MyISAM for some specific reason.

From: 99% of gargoyles look like (MR_BASTARD)16 Nov 2009 11:46
To: DSLPete (THE_TGG) 6 of 34
If it helps, as a base rule, you should be using InnoDB unless you know you need MyISAM for some specific reason.

Interesting. The first hit from this query states "In Doubt? MyISAM".
From: DSLPete (THE_TGG)16 Nov 2009 12:47
To: 99% of gargoyles look like (MR_BASTARD) 7 of 34

Good for that link, in my 8 years experience of designing and eeking every bit of performance I can out of mysql databases (we are talking 2000 concurrent queries per second and millions of transactions per day) I have found the opposite to be the case.

 

In fact the only situation where I have seen myisam used in an "enterprise" system since approx. 2003 is where it is solely and knowingly a normalization of existing data, or for its fulltext index.

From: Peter (BOUGHTONP)16 Nov 2009 14:19
To: DSLPete (THE_TGG) 8 of 34
Only 8 years experience? I bet Truffy has many more years than that of searching Google, so I'm going to accept his answer as the correct one. :T
From: 99% of gargoyles look like (MR_BASTARD)16 Nov 2009 14:55
To: DSLPete (THE_TGG) 9 of 34

I wasn't doubting your advice, or experience. The DBs that I develop will /never/ reach the performance requirements that your work does. It's just a tad confusing when you suggest that MyISAM might be preferred for a specific reason, when the best that I can find is full-text indexing. That is all.

 

And Pete, shove it up your arse. Love'n'cuddles, ect.

From: DSLPete (THE_TGG)16 Nov 2009 15:02
To: 99% of gargoyles look like (MR_BASTARD) 10 of 34
Well, you just named one of the specific reasons there, so you have unconfused yourself, I hope.
From: 99% of gargoyles look like (MR_BASTARD)16 Nov 2009 15:16
To: DSLPete (THE_TGG) 11 of 34

But then there's the performance problem that Mark had right at the very start. If I have this correct, MyISAM would be useful for a DB-based site where SELECT queries are the norm, but InnoDB for transactional security and relational integrity (I usually fudge that in the DB design and script). I guess you can choose different engines for the same site, depending on whether there will be more/less SELECT queries.

 

From a personal POV, I could care less about full text indexing. Perhaps I shouldn't be so dismissive of it though.

EDITED: 16 Nov 2009 15:17 by MR_BASTARD
From: DSLPete (THE_TGG)16 Nov 2009 15:24
To: 99% of gargoyles look like (MR_BASTARD) 12 of 34

No, you didn't read what I posted in reply to Mark originally.

 

myisam performance is not just down to the number of SELECTs you have, it's more complex than that and involves taking into account which of your queries will lock the entire table as they execute and which other queries may be running concurrently.

 

Any SELECTs involving joins, UPDATEs and INSERTs (in certain curcumstances) will cause the entire table to be write locked which may or may not be a problem depending on what else is going on at the same time.

 

For Marks tests, he seems to be doing quite intensive operations on a relatively large data set of 4.6m rows. I would hazard a guess that if he introduced some other query types on that data set to run concurrently (as one might get on a high transaction system) he would see some undesired locking situations.

From: milko16 Nov 2009 15:40
To: 99% of gargoyles look like (MR_BASTARD) 13 of 34
you could care less or you could not care less? Which? You say could so I assume that's what you meant, but then your next sentence claims you're being dismissive so I begin to think it's the opposite.
From: Peter (BOUGHTONP)16 Nov 2009 15:40
To: DSLPete (THE_TGG) 14 of 34
Which queries does that "in certain circumstances" apply to - just INSERTs or all three?

(and what are the circumstances?)
From: ANT_THOMAS16 Nov 2009 15:54
To: milko 15 of 34
I was thinking the same. So many people seem to get that statement wrong.
From: Drew (X3N0PH0N)16 Nov 2009 15:57
To: ANT_THOMAS 16 of 34
It's an american usage and as such is... fair enough. I suppose. It grates on me but if that's how they say it then that's how they say it.
From: ANT_THOMAS16 Nov 2009 15:59
To: Drew (X3N0PH0N) 17 of 34
But it doesn't make sense. Surely it's better to just be right and actually make sense. Fools.
From: Drew (X3N0PH0N)16 Nov 2009 16:01
To: ANT_THOMAS 18 of 34
I think it's just missing its second half, much like "great minds think alike...". It's also ore sarcastic I think.
From: DSLPete (THE_TGG)16 Nov 2009 16:02
To: Peter (BOUGHTONP) 19 of 34

MyISAM has a concurrent insert mode, which you can play with to allow it to append records to the end of the data file (rather than hunting for a gap in the middle of the data file) if there is another SELECT in progress, thus avoiding locking that SELECT out.

 

You can tailor it to your individual circumstances.

 

http://dev.mysql.com/doc/refman/5.1/en/concurrent-inserts.html

From: milko16 Nov 2009 19:04
To: Drew (X3N0PH0N) 20 of 34
Is Truffy an American now? I'm so confused!

I mean, if I went around saying "well, that's the way the gryphon crumbles" would you be like "well, he is half Welsh, so it's fine"?