What is the performance difference between “insert ignore” and replace in MySQL?

前端 未结 2 1307
星月不相逢
星月不相逢 2020-12-16 12:23

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

2条回答
  •  无人及你
    2020-12-16 13:16

    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

提交回复
热议问题