@cierek1 One more option.
You can create a temporary table and update using join.
I will use this database as an example.
https://github.com/datacharmer/test_db
Let's take a look at the salaries table.
mysql> desc salaries;
+-----------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------+------+-----+---------+-------+
| emp_no | int(11) | NO | PRI | NULL | |
| salary | int(11) | NO | | NULL | |
| from_date | date | NO | PRI | NULL | |
| to_date | date | NO | | NULL | |
+-----------+---------+------+-----+---------+-------+
4 rows in set (0.01 sec)
mysql> select count (*) from salaries;
+----------+
| count(*) |
+----------+
| 2844047 |
+----------+
1 row in set (0.10 sec)
Now let's create a temporary table in the same format as our salaries table.
CREATE TEMPORARY TABLE temp_salaries LIKE salaries;
Query OK, 0 rows affected (0.00 sec)
In this part you will insert the entire contents of your CSV file into the temporary table. I will simulate this by copying the salaries table data to temp_salaries, I will only change the salary value using the RAND () function.
// FLOOR (RAND () * (MAX - MIN + 1)) + MIN
mysql> INSERT INTO temp_salaries (emp_no, salary, from_date, to_date)
SELECT
emp_no,
FLOOR (RAND () * (1000-10 + 1)) + 10,
from_date,
to_date
FROM salaries;
Query OK, 2844047 rows affected (8.18 sec)
Records: 2844047 Duplicates: 0 Warnings: 0
Let's look at the first 3 of each table.
mysql> select * from temp_salaries limit 3;
+--------+--------+------------+------------+
| emp_no | salary | from_date | to_date |
+--------+--------+------------+------------+
| 10001 | 203 | 1986-06-26 | 1987-06-26 |
| 10001 | 922 | 1987-06-26 | 1988-06-25 |
| 10001 | 27 | 1988-06-25 | 1989-06-25 |
+--------+--------+------------+------------+
3 rows in set (0,00 sec)
mysql> select * from salaries limit 3;
+--------+--------+------------+------------+
| emp_no | salary | from_date | to_date |
+--------+--------+------------+------------+
| 10001 | 60117 | 1986-06-26 | 1987-06-26 |
| 10001 | 62102 | 1987-06-26 | 1988-06-25 |
| 10001 | 66074 | 1988-06-25 | 1989-06-25 |
+--------+--------+------------+------------+
3 rows in set (0,00 sec)
Now we will update the salaries table according to the contents of the temporary table.
mysql> UPDATE
salaries,
temp_salaries
SET
salaries.salary = temp_salaries.salary
WHERE
salaries.emp_no = temp_salaries.emp_no AND
salaries.from_date = temp_salaries.from_date;
Query OK, 2844047 rows affected (53.71 sec)
Rows matched: 2844047 Changed: 2844047 Warnings: 0
Let's see...
mysql> select * from salaries limit 10;
+--------+--------+------------+------------+
| emp_no | salary | from_date | to_date |
+--------+--------+------------+------------+
| 10001 | 203 | 1986-06-26 | 1987-06-26 |
| 10001 | 922 | 1987-06-26 | 1988-06-25 |
| 10001 | 27 | 1988-06-25 | 1989-06-25 |
| 10001 | 332 | 1989-06-25 | 1990-06-25 |
| 10001 | 579 | 1990-06-25 | 1991-06-25 |
| 10001 | 898 | 1991-06-25 | 1992-06-24 |
| 10001 | 761 | 1992-06-24 | 1993-06-24 |
| 10001 | 110 | 1993-06-24 | 1994-06-24 |
| 10001 | 242 | 1994-06-24 | 1995-06-24 |
| 10001 | 868 | 1995-06-24 | 1996-06-23 |
+--------+--------+------------+------------+
10 rows in set (0,00 sec)
We updated 2.8 million in 53 seconds!
Using a Dell Inpirion 5000 Dual Core notebook Intel® Core ™ i7-7500U CPU @ 2.70GHz - 8.0 GB memory.
imagine on a server.
I believe your 80,000 line csv will come easy.
The only challenge will be to transcribe this to Laravel's Eloquent.