Cypher - Neo4j Query Profiling

Viewed 584

I have some questions regarding Neo4j's Query profiling. Consider below simple Cypher query:

PROFILE 
MATCH (n:Consumer {mobileNumber: "yyyyyyyyy"}),
      (m:Consumer {mobileNumber: "xxxxxxxxxxx"}) 
WITH n,m 
MATCH (n)-[r:HAS_CONTACT]->(m) 
RETURN n,m,r;

and output is:

enter image description here

So according to Neo4j's Documentation:

3.7.2.2. Expand Into

When both the start and end node have already been found, expand-into is used to find all connecting relationships between the two nodes.

Query.

MATCH (p:Person { name: 'me' })-[:FRIENDS_WITH]->(fof)-->(p) RETURN
> fof

So here in the above query (in my case), first of all, it should find both the StartNode & the EndNode before finding any relationships. But unfortunately, it's just finding the StartNode, and then going to expand all connected :HAS_CONTACT relationships, which results in not using "Expand Into" operator. Why does this work this way? There is only one :HAS_CONTACT relationship between the two nodes. There is a Unique Index constraint on :Consumer{mobileNumber}. Why does the above query expand all 7 relationships?

Another question is about the Filter operator: why does it requires 12 db hits although all nodes/ relationships are already retrieved? Why does this operation require 12 db calls for just 6 rows?

Edited

This is the complete Graph I am querying: Graph Data

Also I have tested different versions of same above query, but the same Query Profile result is returned:

1

PROFILE
 MATCH (n:Consumer{mobileNumber: "yyyyyyyyy"})
 MATCH (m:Consumer{mobileNumber: "xxxxxxxxxxx"}) 
 WITH n,m 
 MATCH (n)-[r:HAS_CONTACT]->(m) 
 RETURN n,m,r;

2

PROFILE
 MATCH (n:Consumer{mobileNumber: "yyyyyyyyy"}), (m:Consumer{mobileNumber: "xxxxxxxxxxx"}) 
 WITH n,m 
 MATCH (n)-[r:HAS_CONTACT]->(m) 
 RETURN n,m,r;

3

PROFILE 
MATCH (n:Consumer{mobileNumber: "yyyyyyyyy"}) 
WITH n 
MATCH (n)-[r:HAS_CONTACT]->(m:Consumer{mobileNumber: "xxxxxxxxxxx"}) 
RETURN n,m,r;
2 Answers
Related