简体   繁体   English

Neo4j标签,关系类型和密码匹配性能

[英]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 . 由于我正在定义用户及其对节点的访问,因此用户和节点之间存在一种关系类型: 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. 在其他对象之间,存在不同的关系类型,但是出于访问控制的目的,当我们从用户开始时,一切都涉及CAN_ACCESS关系。

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. 我永远不会在不使用标签的情况下进行匹配,因此,我的意图和希望是,通过匹配标签可以消除User节点中一种频繁使用的关系类型对性能的不利影响。 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. 那么,我的问题是,在比赛的目的地使用标签是否等效于在User和任何给定标签之间User专用的关系类型。 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`)? 如果CAN_ACCESS_LABEL_X总是(n:`User`)->(n:`LabelX`)?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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