Best practice for unique IDs in Neo4J and other databases?

天涯浪子 提交于 2020-01-16 01:18:06

问题


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!


回答1:


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/.



来源:https://stackoverflow.com/questions/23870292/best-practice-for-unique-ids-in-neo4j-and-other-databases

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!