4 ms·
Actually for many rows I delete and insert. Much easier to write. DELETE FROM t WHERE id IN (SELECT id FROM new_data); INSERT INTO t SELECT id, other_field FR
by adontz 6y ago
Actually for many rows I delete and insert.
Much easier to write.
DELETE FROM t WHERE id IN (SELECT id FROM new_data);
INSERT INTO t SELECT id, other_field FROM new_data;
It seems so natural to me that I do not have to repeat field list.
Queries were mostly in context of ETL, so never considered performance issues. Never wrote such code for OLTP.
- shmoogy 6y agoThat's an interesting idea, I'll probably borrow this for ETL purposes.
- jimktrains2 6y agoThat'll update all ties though, including fields like created_at that you may not want updated.