gpt4 book ai didi

mysql - 如何理解主键的上端?

转载 作者:行者123 更新时间:2023-11-29 07:26:19 28 4
gpt4 key购买 nike

在书中< High Performance MySQL > 第 177 页,有一个关于“When Primary Key Order Is Worse”的提示

For high-concurrency workloads, inserting in primary key order can actually create points of contention in InnoDB. The upper end of the primary key is one hot spot. Because all inserts take place there, concurrent inserts might fight over next-key locks. Another hot spot is the AUTO_INCREMENT locking mechanism; if you experience problems with that, you might be able to redesign your table or application, or configure innodb_autoinc_lock_mode. If your server version doesn’t support innodb_auto inc_lock_mode, you can upgrade to a newer version of InnoDB that will perform better for this specific workload.

如何理解上端主键的概念?

最佳答案

这本书的意思是“表中使用的主键的当前最大值”。

意思是如果你继续按主键的升序插入,那么你可能会影响性能,因为(在自动递增的情况下)“这个主键的下一个值”是必须自动生成和使用的东西,并且因为(在其他情况下)存在使其速度变慢的实现因素。

如果我有一个表,其中的行的主键值是 1, 2, 3, 4,那么在“上端”插入意味着插入主键值大于 4。显然,在此示例中,您没有太多选择!

关于mysql - 如何理解主键的上端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53542506/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com