title: Laravel migrations/db:seed super slow
body: <p>I recently upgraded from my old Windows computer into a gen. 4 I7 Ubuntu 15.04</p>
  
  <p>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.</p>
  
  <p>The major difference is that instead of XAMPP I'm running MySQL as a local service.</p>
  
  <p>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.</p>
  
  <p>Somewhere around the internet someone said to use <strong><em>'127.0.0.1'</em></strong> instead of <strong><em>'localhost'</em></strong> because of DSN resolution. Didn't solve it.</p>
  
  <p>To make sure that's not the issue i ran</p>
  
  <pre><code>    $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;
  </code></pre>
  
  <p>~halp</p>
  
  <hr>
  
  <p><strong>Edit</strong></p>
  
  <p>I collected the running times for each query from the framework, I have <strong>LOTS</strong> of migrations, analyzing the data I found there's nothing insanely slow (like a query running for a minute). </p>
  
  <p><a href="http://pastebin.com/ytGxJWaK" rel="noreferrer">Here's a link with the data</a>. Actual queries were ommited in favor of my employer. </p>
  
  <p>Although there's many queries running for a second or longer, the slowest, <code>number 221</code> takes a whoping 3.5 seconds. </p>
  
  <p>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.</p>
  
  <p>As suggested by oliverpool, I did some profiling by replaying queries on the mysql via terminal, but <em>I never had to wait longer than a second</em> with the average query taking around thenth of a second.</p>
  
  <p>Here is a pic of the profiling for the slowest query (3.5secs in migration, not close to a second in the pic)</p>
  
  <p><a href="https://i.stack.imgur.com/0u304.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0u304.png" alt="enter image description here"></a></p>
  
  <p>Maybe this points towards the connection? By the way <strong>the slow query log is empty</strong> after running the migrations.</p>
  
  <p>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.</p>
  
  <p><strong>Thanks in advance</strong>.</p>