“插入忽略"与“插入忽略"之间的性能差异是什么?并替换为MySQL? [英] What is the performance difference between "insert ignore" and replace in MySQL?

查看:71
本文介绍了“插入忽略"与“插入忽略"之间的性能差异是什么?并替换为MySQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道MySQL中insert ignorereplace订单之间在性能方面是否存在差异.

I would like to know if there is a difference in terms of performance between insert ignore and replace orders in MySQL.

我正在使用MySQL 5.0.31.我所有的表都在InnoDB中.

I am using MySQL 5.0.31. All my tables are in InnoDB.

推荐答案

插入忽略-如果存在键/行,则跳过插入

insert ignore - if key/row exists, skip insertion

替换-如果存在键/行,则删除匹配行,然后再次插入

replace - if key/row exists, delete the match row, and insert again

因此,replace应该更慢.
但是insert ignore不执行更新

So, replace should be slower.
But insert ignore does not do the update

详细信息: http://dev.mysql.com/doc/refman/5.5/en/replace.html

REPLACE的工作原理与INSERT完全相同,不同之处在于,如果表中的旧行与PRIMARY KEY或UNIQUE索引的新行具有相同的值,则在插入新行之前删除该旧行

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

这篇关于“插入忽略"与“插入忽略"之间的性能差异是什么?并替换为MySQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆