MySQL extremely slow under Snow Leopard

MySQLosx-snow-leopardperformance

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!

Best Answer

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.