V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
loongwang
V2EX  ›  问与答

公司线上一张表 uuid 做索引, 1 个小时内出现 1.6w 条重复。。。

  •  
  •   loongwang · Mar 17, 2018 · 2240 views
    This topic created in 2964 days ago, the information mentioned may be changed or developed.

    用的阿里的集群。

    uuid 一大一部分是客户端生成的,有一小一部分是后端生成的。 后端是用 java 的 UUID.randomUUID()生成的。 这个问题好像一直都有,正常吗?(我是实习生,今天看到了这个问题)

    Supplement 1  ·  Mar 17, 2018
    结贴。 找到问题,和 uuid 无关,两次使用了同一个 uuid 所致。
    3 replies    2018-12-18 13:10:02 +08:00
    doubleflower
        1
    doubleflower  
       Mar 17, 2018 via Android
    你都用 uuid 了,做的不是唯一索引?
    mcoo1997
        2
    mcoo1997  
       Mar 17, 2018 via Android
    没有什么是增加长度解决不了的,如果有的话,那就换一个算法
    honeycomb
        3
    honeycomb  
       Dec 18, 2018 via Android
    还有一种办法是使用有时间戳+机器号(进程号)+顺序号的 UUID,mongo 的自带 id 也只用了 12 字节
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5449 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 08:11 · PVG 16:11 · LAX 01:11 · JFK 04:11
    ♥ Do have faith in what you're doing.