Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel migrations/db:seed super slow

I recently upgraded from my old Windows computer into a gen. 4 I7 Ubuntu 15.04

Runs like a dream, well...Except that any Laravel artisan command that touch the database takes a million years to complete, while my old computer performed any of those commands in seconds.

The major difference is that instead of XAMPP I'm running MySQL as a local service.

Also in my old computer I could see how migrations slowly showed on screen as they appear to be processed while now, it takes like 2~5 minutes and when done the whole migration list is shown at once. This could indicate a bottle neck of sort somewhere.

Somewhere around the internet someone said to use '127.0.0.1' instead of 'localhost' because of DSN resolution. Didn't solve it.

To make sure that's not the issue i ran

    $time = microtime(true);

    //also with host=127.0.0.1
    new PDO("mysql:host=localhost;dbname=some_db", "username", "password");

    //some simple queries here...

    //yielded similar marginal times
    echo microtime(true) - $time;

~halp


Edit

I collected the running times for each query from the framework, I have LOTS of migrations, analyzing the data I found there's nothing insanely slow (like a query running for a minute).

Here's a link with the data. Actual queries were ommited in favor of my employer.

Although there's many queries running for a second or longer, the slowest, number 221 takes a whoping 3.5 seconds.

I have around a hundred migrations(I know) but here's the thing, if each migration took a second I'd be waiting around a minute and a half to migrate, but it often takes from 4 to 5 minutes.

As suggested by oliverpool, I did some profiling by replaying queries on the mysql via terminal, but I never had to wait longer than a second with the average query taking around thenth of a second.

Here is a pic of the profiling for the slowest query (3.5secs in migration, not close to a second in the pic)

enter image description here

Maybe this points towards the connection? By the way the slow query log is empty after running the migrations.

Also, I'm using laravel 5 now and the behaviour is the same. I dont know how to trouble shoot connection so I guess some googling is in order, any suggestions are welcome.

Thanks in advance.

like image 493
JSelser Avatar asked Jul 29 '15 16:07

JSelser


1 Answers

In this case, I think that the buffer pool size increment is required. Set the following:

[mysqld]
innodb_io_capacity = 2000
innodb_read_io_threads = 64
innodb_thread_concurrency = 0
innodb_write_io_threads = 64
like image 124
Navnish Bhardwaj Avatar answered Oct 24 '22 23:10

Navnish Bhardwaj