SELECT vs UPDATE performance with index

后端 未结 7 1763
有刺的猬
有刺的猬 2020-12-09 04:10

If I SELECT IDs then UPDATE using those IDs, then the UPDATE query is faster than if I would UPDATE using the conditions

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 04:58

    Most likely the second UPDATE statement locks much more rows, while the first one uses unique key and locks only the rows it's going to update.

提交回复
热议问题