简体   繁体   中英

Understanding Neo4j Cypher Profile keyword and execution plan

Could someone please explain or provide links where we can learn about the profile command and understand the execution plans of Cypher query for optimization needs and understanding how Cypher works.

For example, I created the following Neo4j(version 2.0) sample database.

create (ayan:Person{name:"Ayan",age:25}), 
(dixi:Person{name:"Dixi",age:26}), 
(thaggu:Person{name:"Thaggu",age:27}), 
(santosh:Person{name:"Santosh",age:28}),
(ayan)-[:FRIEND]-(santosh),
(ayan)-[:FRIEND]-(dixi),
(thaggu)-[:FRIEND]-(dixi);

Now,when i run the simple query below,

profile match n:Person, n-[:FRIEND]-m where n.name="Ayan" return m;

I get the following result, but I am not able to understand the explaination below the result. Please help.

+--------------------------------+
| m                              |
+--------------------------------+
| Node[4]{age:28,name:"Santosh"} |
| Node[2]{age:26,name:"Dixi"}    |
+--------------------------------+
2 rows



==> ColumnFilter(symKeys=["n", "m", "  UNNAMED17"], returnItemNames=["m"], _rows=2, _db_hits=0)

==> PatternMatch(g="(m)-['  UNNAMED17']-(n)", _rows=2, _db_hits=0)

==>   Filter(pred="(Property == Literal(Ayan) AND hasLabel(n: Person))", _rows=1, _db_hits=4)

==>     NodeByLabel(label="Person", identifier="n", _rows=4, _db_hits=0)

the profile information is right now not finished yet and therefore not documented. However, the critical number are the _db_hits that should not be exceptionally high since they are expensive.

Understanding the execution plan

As of Neo4j 2.2 there is a chapter in the documentation that explains the execution plan, see Chapter 16. Execution Plans .

How to profile a query

There is also a new profiling keyword, EXPLAIN , which lets you view the execution plan without executing the query. Finally there is a new, 'cost based' (as opposed to 'rule based') query planner and you can force the use of either of the planners for all queries or for individual queries. See Is there a way to show cypher execution plan? for more details on the new profiling facilities and links to the relevant documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM