Incredibly slow to create tables in MySQL

Creating tables in MySQL is incredibly slow in my containers. I have a single mysql container:

mysql:
  image: mysql:5.5
  volumes:
    - mysqldata:/var/lib/mysql
    - ./mysql/mysql.cnf:/etc/mysql/conf.d/mysql.cnf:ro
  ports:
    - "3306:3306"
  environment:
    - MYSQL_ROOT_PASSWORD=password

The mysqldata container was created with docker volume create --name=mysqldata.
mysql.cnf contains:

[mysqld]

innodb_file_per_table=1

# WordPress's database includes many fields that support MEDIUMTEXT (i.e., ~16M)
max_allowed_packet=16M
skip-host-cache
skip-name-resolve

So this is a fairly standard MySQL container with data stored in a named volume (not mounted from a host directory).

Let’s take a fairly simple WP database. wp.sql · GitHub

Importing this DB takes about 25 seconds, when it should be nearly instantaneous (I’d even accept a couple seconds). Importing a dump of a few dozen MB can take an hour. As a dump is importing, the Activity Monitor in OSX reports that it’s writing at 2-3 MB/s.

What is it so busy writing? Why does MySQL take so long to import such a tiny (25KB) sql dump? How would I even start to analyze this to track down the cause?

I am currently on Docker for Mac Version 1.12.1-beta26.1, but I’ve been experiencing this on every version (both stable and beta) since I first installed beta8.

1 Like

I’m not sure what the issue may have been with previous versions but with Beta 26 and stable 1.12.1 we introduced a fairly major performance regression in the virtual block device component of Docker for Mac due to how we handle disk synchronization events. This regression is tracked by https://github.com/docker/for-mac/issues/668 and a fix is under development.

We are interested in any other issues you may encounter regarding performance of host mounts, Docker volumes, or the virtual block device (storing Docker volumes, image layers, etc).

Thanks for participating in the Docker for Mac Beta!

David

I found that upgrading to 1.21.1 stable caused my test suite to go from ~1 minute to ~8 minutes.

I have found a similar issue with speed when using postgres after an update from 1.12.0 to 1.12.1 on docker. It is now very much slower. Perhaps 10x slower.

I have the same issue that same sql import needs 5m in mac docker, while only needs seconds in linux docker.

My mac docker is stable version 1.12.3 (13776).