mysql 锁的问题

2020-12-25 11:22:56 +08:00
 Chaox

源自 innodb 技术内幕的一句话,只有当实现本身增加开销时,行级锁才会增加开销,innodb 不存在锁升级,一个锁和多个锁的开销是一样的。 这里一个锁和多个锁的开销是一样的的意思是:我如果用了多个行锁和一个行锁的开销是一样?这是不是不太符合逻辑?

749 次点击
所在节点    问与答
2 条回复
lpts007
2020-12-25 12:02:05 +08:00
In the InnoDB transaction model, the goal is to combine the best properties of a multi-versioning database with traditional two-phase locking. InnoDB performs locking at the row level and runs queries as nonlocking consistent reads by default, in the style of Oracle. The lock information in InnoDB is stored space-efficiently so that lock escalation is not needed. Typically, several users are permitted to lock every row in InnoDB tables, or any random subset of the rows, without causing InnoDB memory exhaustion.


->The lock information in InnoDB is stored space-efficiently so that lock escalation is not needed.

-> space-efficiently

大致意思就是行锁开销为 0,n 个行锁开销为 0 * n = 0,这种意思吧。

黑箱知识适度打开,打开多了容易碰见黑洞,耗尽精力也没啥用。很多中文资料看一看就算了,别纠结。
Chaox
2020-12-27 19:01:04 +08:00
@lpts007 好的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/738834

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX