This article was originally published on my website https://coder.today/software-engineer-from-monolith-to-cloud-auto-increment-to-uuid-a62f92f387...
For further actions, you may consider blocking this person and/or reporting abuse
I feel KSUIDs are a good compromise. You have secure IDs like with UUIDs but they are roughly sortable (and you can memorize a bit): github.com/segmentio/ksuid
Wow nice, my brain just got bigger.
Also I found this on the ksuid repo segment.com/blog/a-brief-history-o... which is a good extra for my article.
KSUID look nice, and knowing what Segment.io does I see their need for such a thing.
It is like a json web token with a timestamp and crypto-randomness, sounds like a cookie treat.
I just switched from a PHP/MySQL app with auto-incremented ID to a Go/Mongodb app with UUID.
The main drawback I noticed is that you can't use internal mongodb document's ObjectId for your queries. It makes your code a bit more complex:
With auto-increment:
With UUID:
And it's the same for
update,remove&upsert.Yes because ObjectID is a BSON object, and adds more text along the way.
You can use other types, like a string with a UUID, but you have to provide the
_idat insert and you have to be sure they are unique. MongoDB will add an_idonly if is missing and it will be anObjectId.There is one point here:
Unfortunately, Oracle (unlike MS SQL, MySql) doesn't support an auto-increment data type. You have to create a combination of sequence and trigger for the PR key column. If I good remember Oracle decided to resign from that type of data structure due to performance reasons.
They got that right, auto increment is a bottle neck in a heavy-write app. But still is funny to see the words Oracle and Performance in the same sentence.