Fork me on GitHub
#datomic
<
2020-05-08
>
alekszelark07:05:10

Hi! What if one wanted to use another randomly generated unique IDs (e.g. nano-id) instead of UUIDs, would Datomic lookup them as fast as UUID?

favila11:05:21

Speed probably isn’t going to differ that much. Uuids have a space-efficient encoding in fressian and transit and are compactly represented in java. An alternative id scheme will have to be represented as a string

alekszelark12:05:45

Thanks for pointing to representation and transferring data, just didn’t think about it. However, the main question about lookup speed is still opened.

favila12:05:50

again, it’s unlikely to make a difference, except insofar as things with smaller representations in memory tend to be faster

favila12:05:19

comparing two longs vs comparing a non-interned string for instance

favila12:05:16

or just being able to fit more of them into a cpu cache

favila12:05:39

if speed is absolutely critical you should benchmark, but my hunch is it doesn’t matter

favila12:05:53

people routinely use string identifiers in datomic

👌 8
alekszelark12:05:19

Thanks a lot.

pvillegas1222:05:42

How can I convert a datom like

pvillegas1222:05:50

#datom[49011830319782294 186 #uuid”c3fc44ab-44a2-4e66-b095-bfe0dc200806" 13194140498706 false] into the vector of data it contains?

favila00:05:35

I’m not sure what you mean? The datom is the data. Do you just want something with same fields but type “vector”?

favila00:05:40

Datoms support nth and get access (using keys :e :a :v :tx :added) so it should be rare you need to convert them