getRows() ->chunk(1000) ->each(function (LazyCollection $chunk) use ($fieldnames) { foreach ($chunk as $row) { $row = array_values($row); $match_id = 0; $ss_player_id = 0; $update_array = []; foreach ($fieldnames as $key => $name) { if ($key == 1) { $match_id = (int) $row[$key]; } elseif ($key == 2) { $ss_player_id = (int) $row[$key]; } else { $update_array[$name] = $row[$key]; } } StatistikoPlayer::updateOrCreate( [ 'match_id' => $match_id, 'ss_player_id' => $ss_player_id, ], $update_array ); } }); /**update statistic player tabel */ UpdatePlayerSeasonHelper::update(1000000); } }