简体   繁体   English

通过Cypher在Neo4j中找到两个节点之间的路径很慢

[英]Finding path between two nodes in Neo4j via Cypher is slow

I intend to find the path between two nodes: 我打算找到两个节点之间的路径:

MATCH (x:Column {name:'colA', schema:'a.b'})-[cd:CD*1..]->(y:Column {name:'colB', schema:'c.d'})
RETURN x,y;`

and the explain is illustrated below: 解释如下:

图片

After executing the above cypher, it looks like stuck forever without returning anything. 执行上述密码后,它看起来永远卡住了,没有返回任何东西。 I think the culprit is the VarLengthExpand phase, the Neo4j version is enterprise-3.4.0 , any suggestions? 我认为罪魁祸首是VarLengthExpand阶段,Neo4j版本是enterprise-3.4.0 ,有什么建议吗? Thanks. 谢谢。

First of all, upgrade. 首先,升级。 You're using a .0 release, and these are usually the most buggy kinds of releases (aside from the alphas). 您正在使用.0发行版,这些发行版通常是错误最严重的发行版(除了alpha之外)。 At the least, get to the latest patch release for the minor version you're interested in (so in your case, if you want 3.4.x, get the latest patch along the 3.4.x line). 至少,请获取您感兴趣的次要版本的最新修补程序版本(因此,如果您要使用3.4.x,则应从3.4.x版本获得最新的修补程序)。

Secondly, as both of these nodes can be looked up via the index, and as it seems you're only looking for a single path, not all possible paths, you may want to make use of shortestPath() after matching upon both of the nodes. 其次,由于可以通过索引查找这两个节点,并且似乎您只是在寻找一个路径,而不是所有可能的路径,因此您可能希望在匹配两个路径之后使用shortestPath()节点。 Give that a try. 试试看。

MATCH (x:Column {name:'colA', schema:'a.b'}), (y:Column {name:'colB', schema:'c.d'})
MATCH path = (x)-[:CD]->(y)
RETURN path

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

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