mysql UPDATE语句-对于相同值的开销? [英] mysql UPDATE statement - overhead for same values?
问题描述
如果我调用一个将authortype = 10设置为authortype且已将authortype设置为10的更新语句,这会比执行单独的查询来仅选择不是authortype = 10的查询然后更新它们的速度更快吗?
换句话说,如果我将值设置为已经等于的值,这是否比我将值更新为新值快?再次有无数的记录,我想提高效率.
预先感谢
为什么不只是使用
UPDATE dbo.Authors
SET AuthorType = 10
WHERE AuthorType <> 10
并且两全其美.
请注意,对于任何现代数据库引擎而言,数十万条记录都不会造成任何问题.
次要编辑
i have a large MYSQL database with hundreds of thousands of records. i want to update a field in a large number of them, but I am unaware if that field has been updated yet or not.
if i call an update statement that sets authortype=10 and authortype is already 10 will this be faster than doing a separate query to only select those that aren't authortype=10 and then update them?
in other words, if I set a value equal to what it is already, is that any faster than if I am updating a value to something new? again this is with tons and tons of records and I want to be efficient.
thanks in advance
Why not just use
UPDATE dbo.Authors
SET AuthorType = 10
WHERE AuthorType <> 10
and have the best of both worlds.
Note that a few hundred thousands records should pose no problem for any modern database engine.
Minor edit
这篇关于mysql UPDATE语句-对于相同值的开销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!