简体   繁体   English

Neo4j - 关系方向是否影响密码性能?

[英]Neo4j - Does relationship direction affect cypher performance?

Something I've always been curious about. 我一直很好奇的东西。

(Assuming you could magically flip the directions of relationships in neo4j) (假设你可以神奇地翻转neo4j中的关系方向)

Which would be faster? 哪个会更快?

START a=node(345)
MATCH (a)<-[:foo]-(b)<-[:bar]-(c)
RETURN c

or 要么

START a=node(345)
MATCH (a)-[:foo]->(b)-[:bar]->(c)
RETURN c

Or does it not matter, as under the hood, you can traverse in either direction? 或者无关紧要,在引擎盖下,你可以向任何一个方向移动?

Found the answer in the javadocs ( http://api.neo4j.org/current/org/neo4j/graphdb/Relationship.html ) 在javadocs中找到了答案( http://api.neo4j.org/current/org/neo4j/graphdb/Relationship.html

Even though all relationships have a direction they are equally well traversed in both directions so there's no need to create duplicate relationships in the opposite direction (with regard to traversal or performance). 尽管所有关系都有一个方向,但它们在两个方向上都可以很好地遍历,因此不需要在相反的方向上创建重复的关系(关于遍历或性能)。

That answers that. 这回答了这一点。

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

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