好消息,UUIDv7 https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#v7
UUID version 7 features a time-ordered value field derived from the widely implemented and well known Unix Epoch timestamp source, the number of milliseconds seconds since midnight 1 Jan 1970 UTC, leap seconds excluded. As well as improved entropy characteristics over versions 1 or 6. Implementations SHOULD utilize UUID version 7 over UUID version 1 and 6 if possible.
https://www.foxhound.systems/blog/time-sorted-unique-identifiers/
自增bigint 优点 有序,可预测(CPU prefetch),数量大,表征时间,类似create_at,可读性好,方便看/定位 缺点,坦克问题:被摸到数据信息(简单hash混淆一下),多机时序问题(id不同)
UUID UUIDv4 8-4-4-4-12 优点 随机 自带混淆,跨系统 缺点 随机,index无法预测从而变成memory bound,体积大,浪费, 可读性差(简单hash简化一下?)
好消息,UUIDv7 https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#v7 UUID version 7 features a time-ordered value field derived from the widely implemented and well known Unix Epoch timestamp source, the number of milliseconds seconds since midnight 1 Jan 1970 UTC, leap seconds excluded. As well as improved entropy characteristics over versions 1 or 6. Implementations SHOULD utilize UUID version 7 over UUID version 1 and 6 if possible.
TSID 结合snowflake ID和ULID
ULID能排序,但不递增
Snowflake递增,但不严格排序
有着snaoflakeid一样的问题,70年
一个实现,https://github.sheincorp.cn/f4b6a3/tsid-creator
支持内置base32编码支持 https://www.crockford.com/base32.html 可读性好
横向对比