5 ms·
Query : For people who recommend UUIDs as a unique identifier in a distributed sytem, does the above satisfy the need? In the SO answer[0] uuid v4 is being rec
by abhishekjha 6y ago
Query : For people who recommend UUIDs as a unique identifier in a distributed sytem, does the above satisfy the need?
In the SO answer[0] uuid v4 is being recommended but that is the most random version of uuid. Isn't that going to hurt the b-tree performance by having a very high fanout? How does it help the primary index?
[0] : https://stackoverflow.com/questions/33274291/postgresql-uuid-or-sequence-for-primary-key https://stackoverflow.com/questions/33274291/postgresql-uuid...
EDIT : Apologies. I meant low fanout. What I meant was that you need something ordered to have a better organised b-tree node. If all values are random, each node will have a lot of children, increasing the search space. It might turn into Linked list in the worst case scenario.
- tomsmeding 6y agoExcuse my possible ignorance, but how is more entropy in a primary key going to hurt index performance? The fanout in a b-tree is completely in control of the database, and not dependent at all on properties of the data — apart, of course, from the size of the data, since typically the node fanout is precisely the number of fields that fit in one disk page. Randomness does not influence the size of a UUID on disk.
- rapidlua 6y agoWith random keys updates are going to touch way more pages than with sequential ones. It increases IO due to more dirty buffers and journaling.
- tomsmeding 6y agoPoint taken. Quite true.
- Tostino 6y agoMore reading on this for Postgres: https://www.2ndquadrant.com/en/blog/sequential-uuid-generators/ https://www.2ndquadrant.com/en/blog/sequential-uuid-generato...
- mytailorisrich 6y ago> Isn't that going to hurt the b-tree performance by having a very high fanout? High fanout helps minimise the depth of the tree and therefore helps performance as it minimises the number of nodes to check.
- abhishekjha 6y agoSorry, I meant low fan out, as in a b-tree node will end up have having a lot of singular valued children ultimately degrading to linked list.
- mytailorisrich 6y agoI think random binary keys are pretty good for B trees because they also lead to shallow depth and a balanced tree instead of potentially degrading to a linked list.
- StreamBright 6y agoWe moved away from UUIDs for different reasons. It is hard to work with UUIDs when multiple entities have them. You do not know if you are looking at a user or a group if both is just a UUID. We created our own IDs with prefixes and using base58 encoding for the random part, for example: user-AhnPpn7CbbwPykmux11LJ39Jk. It has the same amount of randomness in it and we can understand what we are looking at.
- DJBunnies 6y agoUuid v5 is namespaced.
- skissane 6y agoBut given a v3 or v5 UUID, you can’t tell what namespace it belongs to. Both are one way functions from (namespace,name) -> uuid. The gp is asking for a way to tell user uuid apart from group uuid just by looking at the uuid. That is actually possible with the v2 uuids used with DCE. But, since just about nobody uses DCE any more, just about nobody uses v2 uuids either
- globular-toast 6y agoWhy would you ever be in a situation where you have a UUID but don't know what it refers to?
- seppel 6y ago