Aerodynamika
Aerodynamika

Reputation: 8433

Best practice for unique IDs in Neo4J and other databases?

Currently in my Node.Js app running on Neo4J I use node-uuid module for giving unique IDs to my database objects.

Using uuid.v1() function from that module I get something like

81a0b3d0-e4d0-11e3-ac56-73f5c88681be

Now, my requests are quite long, sometimes hundreds of nodes and edges in one query. So you can imagine they become huge, because every node and edge has to have a unique ID.

Do you know if I could use a shorter ID system in order to not run into any problems after the number of my items grow? I mean I know I could get away with just the first 8 symbols (as there are 36^8 > 2 Trl combinations, but how well will it perform when they are randomly generated? As the number of my nodes increase, what is the chance that the randomly generated ID will not fall into the already existing ones?

Another question - how to swap the current ID system to the new one? What would be the best way of regenerating the new, shorter IDs?

Thank you!

Upvotes: 1

Views: 3104

Answers (1)

fbiville
fbiville

Reputation: 8970

One option is to move the UUID generation to the database side via the unmanaged extension developed here: https://github.com/sarmbruster/neo4j-uuid.

The whole idea is detailed here: http://blog.armbruster-it.de/2013/08/assigning-uuids-to-neo4j-nodes-and-relationships/.

Upvotes: 4

Related Questions