Earlier quoted context omitted.
More importantly if you have an index on purely random IDs, then each insert will go to some random position into the tree whereas having IDs that increase with time will make all new IDs end up at the end of the tree which reduces index fragmentation.
Or, you could use a graph database and stop having frustrating relational impedance mismatch, nonlocality etc. You can have O(1) lookups instead of O(log N) for almost everything
Nanosecond timestamp collisions are common
111–120 of 291 posts
Re: Nanosecond timestamp collisions are common
#112Earlier quoted context omitted.
But shouldn't that be a separate field then?
I am curios about this, and might be misunderstanding what you mean. Can you layout a demo architecture where you use multiple keys like you propose?
And on top of all that, there are efficiency concerns.
That said, at least for join tables AFAIK - there aren't often a need for row IDs beyond the involved foreign keys - unless you need to add meta data from other relations/tables...
Re: Nanosecond timestamp collisions are common
#113Earlier quoted context omitted.
I'll also have the need to make namespaces dynamic and centrally coordinate their lifecycle along with the rest of my infrastructure as I stand up anything that needs some sort of coordinated ID. So I've just moved this issue to an even larger scope with even more complexity. What do I gain for this? UUIDs solve all of this because the chance of creating a duplicate is so low it can effectively be ignored. I can name…
When you get used to this basic principle of when you create something, the creator slaps a name on it, it stops being considered a hassle or confusing. More specifically: 1. When you create something, the creator names it. 2. When you bring something you created outside your scope, you prepend your name to it. It's kind of what we do with (actual) children if you think, slightly less structured, but the idea was alw…
Re: Nanosecond timestamp collisions are common
#114Earlier quoted context omitted.
Or, you could use a graph database and stop having frustrating relational impedance mismatch, nonlocality etc. You can have O(1) lookups instead of O(log N) for almost everything
How big is the 1 though?
For example, when a user has 7 articles. Do you want to just point to where the articles are stored? Or do you want to do O(log n) lookup for each article?
And if you have many-to-many, do you want to join an Intermediate Table for even more processing, or just follow a pointer to a range of an intermediate node directly and traverse?
Re: Nanosecond timestamp collisions are common
#115Problem solved for the next 200 years.
Re: Nanosecond timestamp collisions are common
#116I get the current time in microseconds, and increment by one nanosecond for each call between updates. Problem solved for the next 200 years.
Re: Nanosecond timestamp collisions are common
#117I get the current time in microseconds, and increment by one nanosecond for each call between updates. Problem solved for the next 200 years.
Re: Nanosecond timestamp collisions are common
#118This is why you should use ids that combine both a time component and a sequence. Eg UUIDv7 has a milliseconds time component and then a field that increments for each event in the same millisecond, and then enough random bits to make collisions between ids generated on different machines astronomically unlikely. Of course there are only so many bits so you might generate too many events in the same time slice so the…
They’re not in tree yet but there are a bunch of awesome pg extensions that provide access to uuidv7 (outside of just using it at the application level)
Re: Nanosecond timestamp collisions are common
#119If you want unique identifiers, use version 4 (random) UUIDs. Problem solved. The probability of a collision is roughly the same as the probability of a fully grown dinosaur spontaneously manifesting in your bedroom due to quantum fluctuations.
Knowing nothing about UUID v4 generation, I have likely a stupid question. What makes you so confident that all implementations and their entropy sources are flawless enough to make actual collision probability close enough to theory?
In the end we have to make some assumptions about the correctness of (some of the) components.
Re: Nanosecond timestamp collisions are common
#120Earlier quoted context omitted.
How big is the 1 though?
Look, if you have N items related to X, at insert time, you store them in an array and have X point to that array, instead of foreign keys. For example, when a user has 7 articles. Do you want to just point to where the articles are stored? Or do you want to do O(log n) lookup for each article? And if you have many-to-many, do you want to join an Intermediate Table for even more processing, or just follow a pointer t…