Laravel migrations/db:seed super slow

五迷三道 提交于 2019-12-30 16:22:08

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/31706146/laravel-migrations-dbseed-super-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!