您的位置:首页 > 其它

提高cypher语句执行效率

2016-04-16 19:53 183 查看
尽量使用参数

这是因为cypher的缓存机制,相同的query执行第二遍会快很多

避免笛卡尔积

笛卡尔积会让执行时间爆炸式的增长

match (a),(b)
return *


在写上上述笛卡尔积式时,请一定确保用where过滤过了

下面也是一种情况

match (u:user)-[:purchase]->(i:item)
where ...
with u, i
match (foo)-[:relate]->(bar)
return *


避免在where语句中做匹配

match (u:user)-[:viewed]->(i:item),(u)-[:purchase]->(other:item)
where u.id=123123
and (i)-[:related_to]->(other)
return i


可以换成这样来写

match (u:user)-[:viewed]->(i:item),(u)-[:purchase]->(other:item)
where u.id=123123
with i,other
match (i)-[related_to]->(other)
return i


拆分较长的match语句

stackoverflow…
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: