Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

[deleted]


According to the docs, a delete+insert is exactly what is does: http://dev.mysql.com/doc/refman/5.1/en/replace.html


That's what MySQL's REPLACE does, but not what "upsert" means: http://en.wiktionary.org/wiki/upsert

In presence of foreign key constraints for example, DELETE+INSERT might break/fail when UPDATE+INSERT will not. Also, the performance characteristics might be different.


Exactly, the original post (which seems to have been deleted) was claiming otherwise :)


If foreign key constraints are deferred, they would be equivalent. It may not be perfect but it's a useful parallel I thought.


Looks like you have to be careful of any ON DELETE CASCADE constraints as it could delete more than you bargain for.


I agree. DELETING when you want to do an UPDATE or INSERT just seems wrong on all levels. DELETING is dangerous and I tend to prefer slightly slower performance of UPSERT with UPDATE/INSERT than involving a delete in the operation.


You're right. Sorry.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: