且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Laravel Migrations/db:seed超级慢

更新时间:2023-11-17 17:51:10

在这种情况下,我认为需要增加缓冲池的大小.设置以下内容:

[mysqld]
innodb_io_capacity = 2000
innodb_read_io_threads = 64
innodb_thread_concurrency = 0
innodb_write_io_threads = 64

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)

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.

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