Is mysql UPDATE faster than INSERT INTO?(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?
推荐答案
插入会更快,因为更新需要先搜索要更新的记录,然后再执行更新.
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 快吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mysql UPDATE 比 INSERT INTO 快吗?
基础教程推荐
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 无法解决整理冲突 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
