Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
810 views
in Technique[技术] by (71.8m points)

php - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...