Neo4j how to avoid supernodes

后端 未结 2 1700
夕颜
夕颜 2021-01-19 12:23

In my Neo4j project I have Role and Permission entities which represent user roles and permissions. Each User in the system has relati

2条回答
  •  半阙折子戏
    2021-01-19 13:10

    Do you plan to make some aggregate/mass queries based on Roles (i.e. count number of people of certain role, list them)?

    If not, and you just want to check if a specific user has certain Role, than in my humble opinion it should not cause difficult to maintain, important performance issues ( as you will traverse certain relationships of the graph, ignoring vast majority of multiple relations of your "supernodes" ). I would keep with simple design ( "premature optimization is the root of all evil" ;) ), and once problems are noticed (internally, relationships are stored in a linkedlist-like structure, so finding a proper one may take time on supernode, even if you restrict searching to a certain relation type), splitting Role nodes using meta-node approach should do the job (it's described in Learning Neo4j)

    If yes, you have a problem. That's probably a field in which RDBMS are better... Using meta nodes probably won't help, as you will still to have process all of them to list/count all users... So caching that data in a separate store may be simply the best idea ...

提交回复
热议问题