IDs sequenced by time?
See original GitHub issueHi there
I’m using uuid.v1()
for keys within my LevelDB + node.js app. Whenever I list entries from the LevelDB, the sorting happens by these keys and unfortunately it is very random.
I mean, in a boring relational DB you increment the primary keys. Whenever you query the rows, the are sorted by these primary keys as a default behavior. This is good, you always know that recently inserted rows appear on top.
But with UUIDs v1 as keys, the sequence is pretty random.
Is there a solution for that? Do I need to fine-tune some options to achieve that behavior or can this be implemented at all in a new version?
Issue Analytics
- State:
- Created 10 years ago
- Comments:21 (9 by maintainers)
Top Results From Across the Web
IDs sequenced by time? · Issue #75 · uuidjs/uuid
I'm using uuid.v1() for keys within my LevelDB + node.js app. Whenever I list entries from the LevelDB, the sorting happens by these...
Read more >Generating unique IDs in a distributed environment at high ...
Learn what it takes to generate unique IDs in a distributed environment at high scale with time sortable guarantees.
Read more >Sequence Identifiers - NCBI - NIH
Each time a sequence record is changed, it is assigned a new GI number. A nucleotide sequence GI number is shown in the...
Read more >Assign group id to sequence of concecutive unique values ...
In a data frame ordered by time, measurements that should be grouped can be identified by sequences of unique device Ids. The problem...
Read more >Sequencing Events (timestamp vs. nanos vs. sequential ...
I'll be using timestamp anyway, but I'm guessing its too coarse to sequence by, particularly if a command generates multiple events.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sm2017: Good question.
I edited my last comment to remove the four field form (the one that resulted in
clockseq
being the primary sort field). Readers should just stick to thereplace(/^(.{8})-(.{4})-(.{4})/, '$3-$2-$1')
form.While an argument can be made for including
clockseq
in the sort order because it gets incremented if there’s a system clock regression, the fact it is randomly initialized on process startup makes it unsuitable for inclusion in sorting. (Including it in my previous comment was a mistake on my part. My apologies for the confusion.)What this means is that in the (very rare?) case where the system clock regresses (goes back in time), the sort order won’t reflect the order in which ids were generated. I expect that’s a minor concern for most folks, however.
(Note: The behavior of
clockseq
described here is part of the 4122 spec, where the intent is to minimize the risk of uuid collisions.)Dealing with non-standard id formats is a slippery slope to which there is no bottom. And since this can pretty easily be bolted on outside of this module I don’t see any particular reason to include it here. Sorry. 😕