4 ms·
"Now, for reasons I can’t explain, people just love GUIDs in database designs." Yeah - they seem kind of silly and meaningless, so instead you use sequential i
by EzGraphs 13y ago
"Now, for reasons I can’t explain, people just love GUIDs in database designs."
Yeah - they seem kind of silly and meaningless, so instead you use sequential integers. After all, they work nicely with object-relational frameworks like ActiveRecord, they are sequential, and they are more "human readable". And then one day you have a subset of data that you need to migrate from one environment. And when you try, you end up with some clashing records created in the target environment. No big deal, you will just increment all of your sequential integers so that there are no clashes. Oh wait, there are foreign keys - need to update those as well. Which reminds me, what is going to happen when ids in the target system catch up the the ones imported. OK we can change the sequence to cause it to start adding records after the one imported. Hey, this is really kind of complicated. There must be an easier way...
Hmmm... about those GUIDs? They completely eliminate an entire class of problems that occur when migrating data across environments (a very common scenario in some quarters).
If this type of scenario never will arise for you, then GUIDs may not make sense for your application. Hopefully this does explain why some "people just love" them.
- SomeRandomUser 13y agoI've never worked with big databases so bare with me if this is a really silly question. Let's say I have database A with sequential IDs, and database B with sequential IDs. Couldn't I just translate the sequential IDs to GUIDs in both databases, merge them to database C and then translate the records from A and B to sequential IDs? Or modyfying IDs is a big no-no in this scenario?
- zrail 13y agoModifying IDs is a giant pain in the ass. At several previous jobs we've had to rekey billions of records with sequential IDs and it never ever goes correctly the first (or tenth) time, and when it eventually does work it takes forever to complete.
- jasonlotito 13y agoTo be fair, he seemed to be referring to non-sequential GUIDs. And I can understand his point. If the only thing a GUID provides is a unique ID, it's not doing much with all that room it takes up.
- merlincorey 13y agoI didn't even know there were actual sequential GUIDs until I just googled for them. Thanks! Seems they are mostly just like autoincrement integers with the random GUID data following. I guess you still have the storage constraints, but now you at least can order them easily.
- jasonlotito 13y agoJust in the interest of sharing more on IDs, I found this an interesting read: http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram http://instagram-engineering.tumblr.com/post/10853187575/sha...