简体   繁体   中英

Neo4j labels, relationship types, and cypher matching performance

Say I have a massive graph of users and other types of nodes. Each type has a label, some may have multiple labels. Since I am defining users and their access to nodes, there is one relationship type between users and nodes: CAN_ACCESS . Between other objects, there are different relationship types, but for the purpose of access control, everything involves a CAN_ACCESS relationship when we start from a user.

I never perform a match without using labels, so my intention and hope is that any performance downsides to having one heavily-used relationship type from my User nodes should be negated by matching a label. Obviously, this match could get messy:

MATCH (n:`User`)-[r1:`CAN_ACCESS`]->(n2)

But I'd never do that. I'd do this:

MATCH (n:`User`)-[r1:`CAN_ACCESS`]->(n2:`LabelX`)

My question, then is whether the use of labels on the destination side of the match is effectively equivalent to having a dedicated relationship type between a User and any given label. In other words, does this:

MATCH (n:`User`)-[r1:`CAN_ACCESS`]->(n2:`LabelX`)

Give me the same performance as this:

MATCH (n:`User`)-[r1:`CAN_ACCESS_LABEL_X`]->(n2)

If CAN_ACCESS_LABEL_X ALWAYS goes (n:`User`)-->(n:`LabelX`)?

正如迈克尔饥饿的评论中指出,马克李约瑟的博客文章在这里表明,性能最好的,当你使用一个专用的关系类型,而不是依赖于标签。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM