Dears,
Actually, I would like to know the best solution to manipulate BIG DATA in LARAVEL/MYSQL.
In my system, am uploading daily excel file (5K rows) into my DB, in case I find the same row in my table so I don't insert it, and if I find the same row, I changed the uploaded date in my DB.
Every time I upload the excel, am checking each row if exist in my table (table contain > 50K) with a normal array like the below
$res = policies::where('phone', '=', $row['phone'])
->where('draft_no', '=', $row['draftno'])
->where('due_date', '=', $duedate)
->where('status', '=', $stat)
->where('bord_date', '=', $borddate)
->where('amount', '=', $row['amnt'])
->where('remarks', '=', $row['remarks'])
->exists();
if(!$res) {
// insert row ($table->save())
}
else {
//update uploaded date to this row.
}
this process takes lots of time bcz each time is checking the table. I tried to use array_chunk in order to insert, but still, the load is big (15 min to 20 min) to finish
Your advice are highly appreciated.
Thanks