I would like to store UUID as a property of a node, the documents and resources I've found regarding this topic are storing UUID as a string in the database.
Is there any way to store UUID as 16 byte integer in the node?
UUID data type are available in other db like SQL Server for example, using a string instead of a 16 bytes integer is a big loss of memory, specially if you have a lot of nodes.
Here are the data types supported by Neo4j
You can store values as an neo4j Integer, which I believe is equivalent to a java long (signed 64-bit integer, which is 8 bytes). One could store 16 bytes in two Integer properties, but I generally think of UUIDs as unsigned values, so that aspect might complicate things. If you end up storing the UUID in a string, I'd use base 16 (hex), it would reduce the string length.
neo4j byte array is another option, depending on the specifics it might be better than string or two Integers
I second f.galluzzi 🙂
I'm not well enough versed in complexity theory to say anything about whether 16-byte Guid/uuid binary values would have appreciable performance gains over 36-byte utf8 strings for b-tree indexes and lookups.
I suspect it wouldn't matter much performance-wise, as the amount of information in a text-uuid is still a maximum of 64 bits. You only care about how many comparisons you need to make to reach a leaf node after all, which would be similar on average. If you have a lot of uuids the extra 20 bytes per record (and transaction log etc) quickly adds up, though. More than double the storage size than it needs is a waste in any case.
I gather that neo4j already knows about 16 bit binary through apoc's uuid feature. Maybe this could be enhanced with a "set uuid"-function as I have seen suggested in one of my searches? I couldn't find a way to do it, though.
For my part a plain indexable generic (var)binary type would be more than enough, the conversion can easily be done in most languages that integrate with a neo4j database. In addition that would enable storing of any datatype from any architecture without needing the db engine to be aware of, say, byte arrays as a type 🙂
PS I'm not looking through the Python lens, in addition the link is dead and the post is to vague for me to find what it might be. For a lot of data it might be worth converting to b64 (24 bytes?) for a 33% saving, though, if that's what Joel referred to in his Python comment.
It would be great to have UUID indexes but there is no such corresponding decimal primitive type in Java. Therefore I'm not sure this will be implemented in Neo4j. But who knows? 😄 In the meantime, as a workaround, I'm redirecting to my contribution to APOC. With this feature you can use B64 encoded UUID as you suggested ==> https://community.neo4j.com/t/store-uuid-as-16-bytes-integer/18324