gpt4 book ai didi

sql - 对于整数类型的主键,为什么避免间隙很重要?

转载 作者:行者123 更新时间:2023-12-01 00:15:57 24 4
gpt4 key购买 nike

我正在为表生成代理键,由于我的高/低算法,每次重新启动/重新启动机器时,可能会出现间隙。

T1: current hi = 10000000 
(sequence being dished out .. 1 to 100)
Assume that current sequence is 10000050

T2: restart system.

T3: System gives out the next_hi as 10000100
(sequence being dished out now ranges from 101 to 200)

T4: Next request for a key returns 100001001

从主键或索引内部的角度来看,为什么序列中没有间隙很重要?我问这个是为了更深入地了解 mysql。

最佳答案

From a primary key or indexing internals perspective, why is it important that there be no gaps in the sequences?

这并不重要 - 是什么让您相信它是重要的?
与主键相关的所有重要事项是它对表中的所有数据都是唯一的。不管值是什么,或者之前和之后的记录是否是顺序值。

关于sql - 对于整数类型的主键,为什么避免间隙很重要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2535483/

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