3 ms·
>When your IDs are random however, each new record has to be placed at a random position. This means a lot more thrashing of data to and from disk. // Just use
by pbhjpbhj 12y ago
>When your IDs are random however, each new record has to be placed at a random position. This means a lot more thrashing of data to and from disk. //
Just use the GUID externally and use have a sequential primary key as the table index?
- zackbloom 12y agoThe issue is with distributed systems where you have multiple actors all needing to insert records with minimal coordination. Using random ids is also very helpful when you want to be able to generate records on the client and then sync them to the server later. In either case, it's difficult to know what that sequential primary key should be.
- pan69 12y agoExactly. I never expose my database Id's to the outside world but generate a random token for each of my objects that has to be. This token is then translated to a database Id which is then used from then on. This allows for the greatest flexibility.
- zackbloom 12y agoThat's not going to be the most efficient option, as it means all your indexes need to include both the primary key, and this secondary id. I would encourage you to think about just using the random token as the primary key.
- ninjaplease 12y agoWhat on earth? Are you going to be changing object ids? Is knowing an object's id an attack vector? Sounds like you are doing it wrong.
- ninjaplease 12y agoReading comprehension fail?