Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql runs remarkably slower on my MacBook versus other environments

Tags:

mysql

macos

I would like to speed up my MySQL on my MacBook. It's much slower than MySQL running on our servers or on virtual machines on other laptops.

All the tables I deal with are InnoDB. I run a lot of django unit tests so there are a lot of create table commands that get run.

Update:

I should note that I'm really comparing this to another laptop, running a Fedora VM, with no tweaks to my.cnf and not a particularly fast hard drive. I also know that our servers run this fairly fast, but I can accept that.

My guess is it still may be a hard disk issue.

like image 541
dd. Avatar asked Nov 15 '22 13:11

dd.


1 Answers

One thing to keep in mind: your MacBook has a laptop hard drive. Even if it's 7200 RPM, you should expect it to be slower, certainly slower than even a modest server hard drive.

And even on a super speed machine, django's test suite blows up all of the database caches, since it rebuilds the database each time it's run.

You can run the unit tests in memory though, which is orders of magnitude faster:

Create a new testsettings.py file next to your app’s settings.py containing:

from projectname.settings import *
DATABASE_ENGINE = 'sqlite3'

Then when you want to run tests real fast, instead of manage.py test, you run

manage.py test --settings=testsettings

Read more here.

I've also experimented with locating the MySQL database entirely on a RAM disk. Unfortunately, I haven't worked that out on Mac OS X yet.

(all of this assumes that there isn't something seriously wrong with your mysql configuration :)

like image 135
Seth Avatar answered Dec 10 '22 04:12

Seth