When are you truly forced to use UUID as part of the design?

前端 未结 16 809
盖世英雄少女心
盖世英雄少女心 2020-11-28 17:39

I don\'t really see the point of UUID. I know the probability of a collision is effectively nil, but effectively nil is not even close to impossible.

16条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 18:00

    To those saying that UUIDs are bad design because they could (at some ridiculously small probability) collide, while your DB generated keys won't... you know the chance of human error causing a collision on your DB generated keys because of some un-forseen need is FAR FAR FAR higher than the chance of UUID4 collision. We know that if the db is recreated it will start ids at 1 again, and how many of us have had to recreate a table when we were sure we would never ever need to? I'd put my money on UUID safeness when stuff starts going wrong with unknown-unknowns any day.

提交回复
热议问题