本文介绍了mysql UPDATE是否比INSERT INTO更快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这更多是一个理论问题.

This is more of a theory question.

如果我正在运行50,000个查询以插入新行,并运行50,000个查询以更新这些行,那么哪一个查询会花费更少的时间?

If I'm running 50,000 queries that insert new rows, and 50,000 queries that updates those rows, which one will take less time?

推荐答案

插入会更快,因为使用update时,您需要先搜索要更新的记录,然后执行更新.

Insert would be faster because with update you need to first search for the record that you are going to update and then perform the update.

虽然这似乎不是一个有效的比较,因为您永远无法选择是插入还是更新,因为两者满足了两个完全不同的需求.

Though this hardly seems like a valid comparison as you never have a choice whether to insert or update as the two fill two completely different needs.

我也应该补充一点,即假设没有插入触发器或其他可能导致潜在瓶颈的情况.

I should add too that this is with the assumption that there are no insert triggers or other situations that could cause potential bottlenecks.

这篇关于mysql UPDATE是否比INSERT INTO更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 06:01