jeudi 5 octobre 2023

How to update 5000+ records in a set of 200s in laravel?

I have a total of approximately 8000+ records. I want to update them in a set of 200s, so that the site which I am working on, doesn't go down due to excessive queries execution. Right now I am not able to do that.

This is my code:

$totalRecords = DB::table('domain_authority_score_update')->where('update_flag', 0);
$reduceRecords = $totalRecords->take(200)->get();

I have used foreach to update all records.

foreach($reduceRecords as $val){
}

I have tried to update them by using for() loop and also do-while() loop, but it didn't give me the expected result.

I have also tried using chunk(). But I did not succeed.

Any help would be appreciated. Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/rHZUoA4
via IFTTT

Aucun commentaire:

Enregistrer un commentaire