Mysql is much slower on my MacBook compared to other environments.

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

All the tables that I do are InnoDB. I run a lot of django unit tests, so there are a lot of table creation commands that run.

Update:

I should note that I am really comparing this to another laptop running Fedora VM, without any changes to my.cnf and not a particularly fast hard drive. I also know that our servers are pretty fast, but I can accept it.

I think this may still be a problem with the hard drive.

+5
source share
5 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, of course, slower than even a modest server hard drive.

And even on a superfast machine, the django test suite explodes all database caches, as it rebuilds the database every time.

You can run unit tests in memory, although this is an order of magnitude faster:

Create a new testsettings.py file next to your settings.py applications, containing:

 from projectname.settings import * DATABASE_ENGINE = 'sqlite3' 

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

 manage.py test --settings=testsettings 

More details here .

I also experimented with placing a MySQL database on a RAM disk. Unfortunately, I have not worked on Mac OS X.

(all of this assumes there is nothing wrong with your mysql configuration :)

+1
source

Have you configured the default MySQL configuration on your Macbook closer to what happens in other environments? The default MySQL settings are very minimal.

I am not familiar with where MySQL is installed on OSX, but you should have some examples of configuration files for different environments: [mysql home] / support files /

Experiment with them by copying them to /etc/my.cnf and restarting MySQL. These sample files are well commented, so this is a pretty good practical way to learn the basic MySQL settings. If you really use InnoDB, you can comment or delete MyISAM settings when everyone tries to save resources.

0
source

A hard drive is one of the factors, but also make sure you check:

 innodb_buffer_pool_size 

If you use innodb, you can change it to something much higher (50% of your RAM or the size of your database). But remember that this amount will actually be used by MySQL, so if you still want to use your RAM for other purposes, you might be better off accepting that your development workstation is not as fast as the server configured for the MySQL database.

0
source

You didn’t tell us what the workload is, reads or updates, or both, but if this is the write intensity, you can try setting innodb_flush_log_at_trx_commit to 0 to be able to disable innodb on * sync () calls - maybe there is bad interaction with the kernel / disk subsystem on the apple OS.

You can also publish my.cnf which you use. It can also be a dns lookup problem if lethargy occurs when connecting to db. To eliminate the dns problem, set skip-name-resolve in my.cnf.

0
source

Well, very late to the party, there was the same problem. I tried every solution that I found, but none helped Finally, just stop and uninstall all mysql instances, then reinstall using brew and start with brew services start mysql fix it.

(Downloading DB tables to 10 MB DB took from 15 seconds to 1.5 seconds).

0
source

All Articles