I would like to know if there is a difference in terms of performance between insert ignore
and replace
orders in MySQL.
I am using MySQL 5
Just a general comment. Insertion implies that what was there before remains. Replacing implies that something that is there already is targeted for removal and the item for insertion is installed in its place. The replacing action must inherently target a item that is already there, remove it and install the new item.
insert ignore - if key/row exists, skip insertion
replace - if key/row exists, delete the match row, and insert again
So, replace
should be slower.
But insert ignore
does not do the update
details : http://dev.mysql.com/doc/refman/5.5/en/replace.html
REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted