views:

410

answers:

3

Hi.

I've installed MySQL 5.1.40 Source distribution (64-bit executable x86_64) following these instructions by Hivelogic and the mysql (2.8.1) gem using ARCHFLAGS="-arch x86_64" .

I'm using it for Ruby on Rails development and my problem is that even if MySQL is working in every way, it is extremely slow.
Take this comparison with sqlite3 when performing a standard rake db:migrate creating about 15 tables.

MySQL:

time rake db:migrate
real 0m4.882s
user 0m1.426s
sys 0m0.235s

sqlite3:

time rake db:migrate
real 0m2.282s
user 0m1.501s
sys 0m0.255s

One also has to consider that about 1.5s of the execution time on each test is loading of the rails framework which means that sqlite3 performs the SQL tasks in about 0.5-1s while MySQL requires more than 3s for the same set of tasks.

Isn't that just plain wrong? What can be the cause of this? Anyone experiencing the same problem?

I have installed and re-installed mysql and mysql/ruby gem several time but always with the same outcome... :(

My Snow Leopard installation is an upgrade and not a fresh installation. Might that be the cause of the problem? Some outdated library?

Thanks!

A: 

This may be the wrong path, but its my understanding that Snow Leopard boots up with a 32-bit kernel by default unless you tell it otherwise (by holding down the 6 and 4 keys during bootup). Could this be something worth considering for your situation? See the attached link for more info.

Snow Leopard 32 Bit / 64 Bit

Nicholas
Irrelevant. The 32 bit kernel has nothing to do with user level processes.
bbum
A: 

From the data in your question, it sounds like you are comparing bananas to oranges.

Specifically, do you have any evidence that the results are even out of line? Comparisons with other platforms running the same tests?

Is this even a test that is relevant to whatever you eventually want to do? I.e. are you testing something that is relevant to the typical set of tasks you will normally be doing or trying to optimize for a one-off task that happens during setup?

Note also that SQLite and MySQL have radically different performance profiles. SQLite is a single-user, non-client/server, database whereas MySQL is typically configured to act in a client/server role. Beyond totally different performance profiles, this also leads to completely different scalability characteristics.

bbum
Thanks for your response bbum!The only comparison I have with another platform is that I ran the same test suit (that uses the above db:migrate) under Leopard and it is now significantly slower under Snow Leopard with execution time taking about 1 min in Leopard and about 3-4 min in Snow Leopard.I've also noticed that mysql seems to "choke" which didn't happen under Leopard. If I try to insert 200 records - the first 30-40 goes lightning fast (~0.8ms) but then it slows down drastically to ~200ms per insert even though the complexity between the first inserts and the last ones is the same.
mrD
OK-- I would suggest using `sample` on both Leopard and Snow Leopard to get a sort of overview where the CPU cycles are going. This may also be due to disk syncing changes between the two OSes. In any case, it is common to need to tune a database to a particular system.
bbum
A: 

Hi,

I have the same issue. I bought a new MacBookPro core i5 with Snow Leopard installed. Installed all my packages from MacPorts, and my test suite runs in 25 secs when it used to run in 2 secs on previous Leopard. A friend who upgraded his Leopard to Snow Leopard ran into the same issue.

What's weird is that no one seems to have an answer. So few resources about the subject when googling "mysql slow on snow leopard". I'm not hardware saavy enough to know all these 32/64 bit stuff, but what I'm sure of is "mysql is damn slow since running on Snow Leopard".

@mrD did you get any improvements since October?

Best

I still don't know what causes it. I've reinstalled all my computers since my initial post and the computer at work (which was the one with the problem) now works fine. I didn't change my installation behavior in any way that I can think of.
mrD
Thanks for the feedback ... still not sorted out on my side ;)