3 ms·
Couldn't you just allocate a pool of IDs to each session (open client), and let the client generate real, unique IDs directly using them? This way you wouldn't
by danmaz74 15y ago
Couldn't you just allocate a pool of IDs to each session (open client), and let the client generate real, unique IDs directly using them? This way you wouldn't need collision detection, synchronization, etc. You only need a big enough IDs space, or a way to reuse IDs of the pool that weren't actually used by the client (by including them in new pools).
- nazar 15y agoI am afraid that would create a mess in a db(its just my guess). Though your idea sounds nice to my ears. The hardest part would be if session runs out of id-s I guess. One can never allocate optimal pool of IDs for every user, there are always going to be "bad cases".
- danmaz74 15y agoIf the id space is big enough, not having optimal pools wouldn't be a problem. And if you are near the exhaustion of a pool, just request a new one...
- bchallenor 15y agoThat's what (N)Hibernate calls the hilo algorithm. Compared with GUIDs, it has the advantage that IDs are somewhat sequential. (Random keys are terrible for index fragmentation.) http://stackoverflow.com/questions/282099/whats-the-hi-lo-algorithm http://stackoverflow.com/questions/282099/whats-the-hi-lo-al...