title: Importing 70k+ rows to database from CSV with efficient memory and execution time
body: <p>Can I get an idea; how can I import 70k+ rows to the database from CSV avoiding a lot of memory usage and time in Laravel (PHP)</p>
  
  <p>Part of my code how I am trying to import:</p>
  
  <pre><code>                $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
                  $reader-&gt;setInputEncoding('UTF-8');
  
  
                  $spreadsheet = $reader-&gt;load($localpath);
  
                  $spreadsheet = $spreadsheet-&gt;getActiveSheet()-&gt;toArray();
                  $collection = LazyCollection::make($spreadsheet);
  
                 if($key==null){
                    $key = array_map('trim', $collection-&gt;first());
                    $key_count=count($key);
                 }
  
                 $collection = $collection-&gt;except(0);
  
                 foreach($collection as $row){
                  if(count($row)==$key_count &amp;&amp; !containsOnlyNull($row)){
                      $array[] = array_combine($key, $row);
                  }
                }
  </code></pre>