title: Inserting many records to database using Laravel's Chunk method becomes slower over time
body: <p>So basically I am trying to import data into around 15 different tables into my database from another. I am chunking the data from the source database, and within that function callback I am inserting it into my database using raw SQL. Code example:</p>
  
  <pre><code>foreach($tables as $table) {    
       DB::connection('source_db')-&gt;table($table)-&gt;select($fields)-&gt;orderBy('id'))-&gt;chunk(2500, function($records) use($table) {
            $this-&gt;runInsertQuery($records, $table);
       });
  }
  </code></pre>
  
  <p>There are around 2 million records total, it seems that it starts out very fast but gets slower and slower as it moves from table to table, taking hours to complete. I was under the impression based on Laravel's documentation that chunking would make inserts run much faster, but it seems to be having the opposite effect. Any guidance would be greatly appreciated!</p>