4 ms·
It says both: > Within the same millisecond, sort order is not guaranteed And: > Monotonic sort order (correctly detects and handles the same millisecond) W
by thih9 2y ago
It says both:
> Within the same millisecond, sort order is not guaranteed
And:
> Monotonic sort order (correctly detects and handles the same millisecond)
Which is it?
To make it more confusing, the spec later contains a section about monotonic sort order[1]. And looks like not all libraries implement it [2].
[1]: https://github.com/ulid/spec?tab=readme-ov-file#monotonicity https://github.com/ulid/spec?tab=readme-ov-file#monotonicity
[2]: https://github.com/suyash/ulid/issues/10 https://github.com/suyash/ulid/issues/10
- GeertJohan 2y agoAfaik it depends on the generate function you use. You can let it keep track of the increment when generating, at a performance cost (atomic operations).
- lukevp 2y agoI think it’s meant to be monotonic within one node but not cross-node (cross-node the sort order is random within the same millisecond). The random portion of the IDs are sequentially incrementing within a single MS on a given node.
- jakjak123 2y agoI think it means all ids from the same node will be monotonic, ie it will never generate a id that will be sorted before an earlier one