I have a very large (millions of rows) database table where I need to add some missing data from a 3rd party to every row.
The data source has a 'reference key' which is my only way to map to the correct item in the table
Each row needs 1 number updated
I can loop through the 3rd party data source and perform an eloquent Update to each row using a unique identifier, but this is very slow from my tests:
Orders
id, reference_key, new_value
int, string, double(8,2)
foreach ($xml as $row) {
Order::where('reference_key', $reference_key)
->update('new_value', (float)$row->new_value);
}
Is there a more efficient way I can do this?