RPG-18 / pg_ulid

Universally Unique Lexicographically Sortable Identifier generate for PostgreSQL
MIT License
11 stars 0 forks source link

Is monotonicity within the same millisecond implemented? #1

Open sergeyprokhorenko opened 3 years ago

sergeyprokhorenko commented 3 years ago

Hi Dmitriy, Have you implemented the monotonicity of ULIDs within the same millisecond? See:

RPG-18 commented 3 years ago

Hi. Yes i got implementation from https://github.com/oklog/ulid/blob/master/ulid.go. But idea ULID with sequence seems interesting. We can store shard id. I will append functions on next weekend.

sergeyprokhorenko commented 3 years ago

I would not recommend making the shard ID mandatory, as in most cases sharding by timestamp of last use is preferable. Outdated data is archived on a tape drive :)

I think there is a very few data that depends on the Instagram style shard ID (on specific user, product or whatsoever).

Nevertheless, there can be a separate function with shard ID too.

sergeyprokhorenko commented 3 years ago

To order ULIDs by creation time, the shard ID must be between the sequence and the random part, or after the random part with increment.

sergeyprokhorenko commented 3 years ago

... after the incremented random part.