neo4j cypher匹配命令串联 [英] neo4j cypher Match command concatenation

查看:112
本文介绍了neo4j cypher匹配命令串联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个Chypher语句是否相同:

are these two Chypher statements identical:

//first
match (a)-[r]->(b),b-[r2]->c

//second
match (a)-[r]->(b)
match b-[r2]->c

推荐答案

2个Cypher语句不同.我们可以使用 PROFILE命令来显示此信息您将了解Cypher引擎如何执行查询.

The 2 Cypher statements are NOT identical. We can show this by using the PROFILE command, which shows you how the Cypher engine would perform a query.

在以下示例中,所有查询均以RETURN a, c结尾,因为您不能有裸露的MATCH子句.

In the following examples, the queries all end with RETURN a, c, since you cannot have a bare MATCH clause.

如您所见,第一个查询具有一个NOT(r == r2)过滤器,而第二个查询则没有.这是因为Cypher确保单个MATCH子句的结果不包含重复的关系.

As you can see, the first query has a NOT(r == r2) filter that the second query does not. This is because Cypher makes sure that the result of a single MATCH clause does not contain duplicate relationships.

  1. 第一个查询

  1. First query

profile match (a)-[r]->(b),b-[r2]->c return a,c;
==> +-----------------------------------------------+
==> | a                     | c                     |
==> +-----------------------------------------------+
==> | Node[1]{name:"World"} | Node[0]{name:"World"} |
==> +-----------------------------------------------+
==> 1 row
==> 2 ms
==> 
==> Compiler CYPHER 2.3
==> 
==> Planner COST
==> 
==> Runtime INTERPRETED
==> 
==> Projection
==>   |
==>   +Filter
==>     |
==>     +Expand(All)(0)
==>       |
==>       +Expand(All)(1)
==>         |
==>         +AllNodesScan
==> 
==> +----------------+---------------+------+--------+----------------+----------------+
==> |       Operator | EstimatedRows | Rows | DbHits |    Identifiers |          Other |
==> +----------------+---------------+------+--------+----------------+----------------+
==> |     Projection |             1 |    1 |      0 | a, b, c, r, r2 |           a; c |
==> |         Filter |             1 |    1 |      0 | a, b, c, r, r2 |   NOT(r == r2) |
==> | Expand(All)(0) |             1 |    2 |      4 | a, b, c, r, r2 | (b)-[r2:]->(c) |
==> | Expand(All)(1) |             2 |    2 |      8 |        a, b, r |  (b)<-[r:]-(a) |
==> |   AllNodesScan |             6 |    6 |      7 |              b |                |
==> +----------------+---------------+------+--------+----------------+----------------+
==> 

  • 第二个查询

  • Second query

    profile match (a)-[r]->(b) match b-[r2]->c return a,c;
    ==> +-----------------------------------------------+
    ==> | a                     | c                     |
    ==> +-----------------------------------------------+
    ==> | Node[1]{name:"World"} | Node[1]{name:"World"} |
    ==> | Node[1]{name:"World"} | Node[0]{name:"World"} |
    ==> +-----------------------------------------------+
    ==> 2 rows
    ==> 2 ms
    ==> 
    ==> Compiler CYPHER 2.3
    ==> 
    ==> Planner COST
    ==> 
    ==> Runtime INTERPRETED
    ==> 
    ==> Projection
    ==>   |
    ==>   +Expand(All)(0)
    ==>     |
    ==>     +Expand(All)(1)
    ==>       |
    ==>       +AllNodesScan
    ==> 
    ==> +----------------+---------------+------+--------+----------------+----------------+
    ==> |       Operator | EstimatedRows | Rows | DbHits |    Identifiers |          Other |
    ==> +----------------+---------------+------+--------+----------------+----------------+
    ==> |     Projection |             1 |    2 |      0 | a, b, c, r, r2 |           a; c |
    ==> | Expand(All)(0) |             1 |    2 |      4 | a, b, c, r, r2 | (b)-[r2:]->(c) |
    ==> | Expand(All)(1) |             2 |    2 |      8 |        a, b, r |  (b)<-[r:]-(a) |
    ==> |   AllNodesScan |             6 |    6 |      7 |              b |                |
    ==> +----------------+---------------+------+--------+----------------+----------------+
    

  • 这篇关于neo4j cypher匹配命令串联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆