在 10 亿次迭代中获得相同 GUID 的机会有多大?

发布于 2024-09-07 09:39:15 字数 107 浏览 1 评论 0原文

我正在开展一个项目,需要生成大约 10 亿个 GUID。

我知道 GUID 不能保证是唯一的,但几乎始终是唯一的。

如果我生成了十亿个 GUID,那么匹配的概率是多少?

I am working on a project where I need to generate approximately 1 billion GUIDs.

I know GUIDs are not guaranteed to be unique but are unique almost all of the time.

If I generated a billion GUIDs, what is the probability that there will be a match?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我三岁 2024-09-14 09:39:15

博文:GUID 是全局唯一的,但 GUID 的子字符串不是

.NET GUID 由

  • 60 位时间戳、
  • 48 位计算机标识符、
  • 14 位唯一标识符组成,其中
  • 6 位是固定的

,所以 Oscar 引用的 UUID 概率在这里不起作用。但是,如果您从一台计算机创建所有 10 亿个 GUID,则没有机会获得重复项(除非您正在玩时钟;-)

Blogpost: GUIDs are globally unique, but substrings of GUIDs aren’t

The .NET GUID consists of

  • 60 bits of timestamp,
  • 48 bits of computer identifier,
  • 14 bits of uniquifier, and
  • six bits are fixed

So the UUID probability quoted by Oscar does not work here. But if you create all your 1 billion GUIDs from one computer, there is no chance to get a duplicate (except you are playing with the clock ;-)

请帮我爱他 2024-09-14 09:39:15

如果您从同一台机器创建 GUId 并使用相同的算法,那么您将不会发生冲突。

If you are creating the GUIds from the same machine and using the same algorithm then you will not get a collision.

我很坚强 2024-09-14 09:39:15

http://en.wikipedia.org/wiki/Uuid#Random_UUID_probability_of_duplicates

概率

68,719,476,736 = 2^36 = 0.0000000000000004 = 4 × 10^−16)

2,199,023,255,552 = 2^41 = 0.0000000000004 = (4 × 10^−13)

70,368,744,177,664 = 2^46 = 0.000 0000004 = (4 × 10^−10)

http://en.wikipedia.org/wiki/Uuid#Random_UUID_probability_of_duplicates

n probability

68,719,476,736 = 2^36 = 0.0000000000000004 = 4 × 10^−16)

2,199,023,255,552 = 2^41 = 0.0000000000004 = (4 × 10^−13)

70,368,744,177,664 = 2^46 = 0.0000000004 = (4 × 10^−10)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文