3 ms·
UUID7 offers several key advantages: - sortable by insertion - less vulnerable to sequence prediction attack - allows partitioning of tables in the futur
by oxfordmale 3y ago
UUID7 offers several key advantages:
- sortable by insertion
- less vulnerable to sequence prediction attack
- allows partitioning of tables in the future
Sequence prediction attack is a problem when you want to use identifiers in a public API. For example, a user or competitor can iterate through your product catalogue by incrementing the key. Sorting by inserting is a common use case as well. You can achieve this with an auto-incrementing primary key, however, this will create issues when you need to partition the table. Of course, you may never need this functionality, but there is a reason UUID7 have been added, as they are very useful in certain scenarios.
- codr7 3y agoI get the public API argument, but it certainly feels backwards to structure the internals of your application for that specific use case. Generating and mapping an UUID to your identifier when you need it is pretty straight forward and allows you to avoid exposing the identifier at all. Which leaves partitioning, something that very few applications will ever need, even if plenty of developers hope they will. A slightly less weird use case, but perfectly doable up to a point using regular sequences. I see a solution looking for problems.
- oxfordmale 3y agoI have build many successful systems without ever using a GUID. However, at a certain scale they become very handy, and it then it definitely helps you can also sort them.
- GoblinSlayer 3y agoJust add a verifier: /item?id=123;vf=ixkdS1Xb Then select * from item where id=123 and vf='ixkdS1Xb'