Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j 哪个密码查询计划更快?_Neo4j_Cypher - Fatal编程技术网

Neo4j 哪个密码查询计划更快?

Neo4j 哪个密码查询计划更快?,neo4j,cypher,Neo4j,Cypher,下面是两个不同的查询及其计划。查询的结果完全相同,但请注意,查询计划不同 关键区别在于使用AllRelationships(identifier=“r”,…)和TraversalMatcher(trail=“(n)-(r其中true和true]->(m)”,…) 问题: 一般来说,哪一个更快?我的猜测是,遍历所有关系比运行任何遍历都要快,但我不知道 像这样的东西会成为优化的目标吗?在这种情况下,return不包括MATCH子句中提到的n或m,这表明不需要遍历 查询: neo4j-sh (?)$

下面是两个不同的查询及其计划。查询的结果完全相同,但请注意,查询计划不同

关键区别在于使用
AllRelationships(identifier=“r”,…)
TraversalMatcher(trail=“(n)-(r其中true和true]->(m)”,…)

问题:

  • 一般来说,哪一个更快?我的猜测是,遍历所有关系比运行任何遍历都要快,但我不知道
  • 像这样的东西会成为优化的目标吗?在这种情况下,
    return
    不包括
    MATCH
    子句中提到的
    n
    m
    ,这表明不需要遍历
  • 查询:

    neo4j-sh (?)$ profile start r=relationship(*) return count(r);
    +----------+
    | count(r) |
    +----------+
    | 100975   |
    +----------+
    1 row
    
    ColumnFilter(symKeys=["  INTERNAL_AGGREGATEdd639fdf-1939-4b9c-ba36-213a0e79fff5"], returnItemNames=["count(r)"], _rows=1, _db_hits=0)
    EagerAggregation(keys=[], aggregates=["(  INTERNAL_AGGREGATEdd639fdf-1939-4b9c-ba36-213a0e79fff5,Count(r))"], _rows=1, _db_hits=0)
      AllRelationships(identifier="r", _rows=100975, _db_hits=100975)
    neo4j-sh (?)$ profile match n-[r]->m return count(r);         
    +----------+
    | count(r) |
    +----------+
    | 100975   |
    +----------+
    1 row
    
    ColumnFilter(symKeys=["  INTERNAL_AGGREGATE961900f2-76e0-40a0-bcab-5e8db2683859"], returnItemNames=["count(r)"], _rows=1, _db_hits=0)
    EagerAggregation(keys=[], aggregates=["(  INTERNAL_AGGREGATE961900f2-76e0-40a0-bcab-5e8db2683859,Count(r))"], _rows=1, _db_hits=0)
      TraversalMatcher(trail="(n)-[r WHERE true AND true]->(m)", _rows=100975, _db_hits=301372)
    

    我猜最上面的查询速度更快,因为列出的db命中数更小。在底部查询中,我认为它正在遍历图中的所有节点。如果您运行以下命令,请尝试此操作:

    start n=nodes(*) return count(n);
    
    我打赌你会得到:301372