【问题标题】:slow neo4j cypher query缓慢的 neo4j 密码查询
【发布时间】:2013-03-05 16:06:34
【问题描述】:

我试图找出为什么我的密码查询运行如此缓慢(仅 5000 个节点需要 2-5 秒)。 该查询试图查找个人资料在其网络中可以访问的所有工作(他的朋友或朋友的朋友在同一家公司工作的工作)

这是查询:

Start current_profile= node:node_auto_index(neoid_unique_id = "Profile:1")
 Match current_profile-[r:friendships*0..2]->friends-[:roles]->company-[:positions]->jobs
 return distinct company.fmj_id

我尝试缩减查询以查看我做错了什么,即使是这个简单的查询也需要太长时间:

START root=node(0)
Match root-[:job_subref]->j-[:jobs]->jobss
return jobss

我做错了吗?

我正在使用基于neography gem的neoid

【问题讨论】:

  • 您能在某处分享您的图表吗?
  • 否则压缩你的数据库目录并上传到某个地方?
  • 也许,这会对你有所帮助(在我的例子中,我通过这个技巧获得了很多加速):使用 with 语句拆分你的 match 语句,即第一个匹配 current_profile-->friends,然后是 friends-->company,最后是 company-->jobs 在单个密码查询中。
  • 是第一次调用(启动 neo4j 后)还是后续调用后的缓慢?记住 Neo4j 从预热缓存中受益匪浅。

标签: neo4j cypher neography


【解决方案1】:

试试这个查询怎么样

Start current_profile= node:node_auto_index(neoid_unique_id = "Profile:1")
Match current_profile-[r:friendships*0..2]->friends
WITH friends
friends-[:roles]->company-[:positions]->jobs
RETURN company.fmj_id

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多