OPTIONAL MATCH

20 views
Skip to first unread message

Marwa Elabri

unread,
Apr 12, 2018, 3:42:21 AM4/12/18
to Neo4j
Hello

please are there another clause that replace optional match in cypher query language 
because I want to get null value from my neo4j database but when I use optional mach with a huge database the request execution takes a lot of time ????

Thank you in advance 

Eve Freeman

unread,
Apr 12, 2018, 8:03:47 AM4/12/18
to ne...@googlegroups.com
Without a query it’s hard to help you on this... 

Often, I tell people to start with a match of what you know exists, and then do an optional match for what you’re not sure exists, like:

match (p:Person) // we want to get all Person nodes 
optional match (p)-[:FOLLOWS]->(maybe:Person)

This way, you give the engine some help with the starting point. Does this help?

Eve

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marwa Elabri

unread,
Apr 12, 2018, 10:00:49 AM4/12/18
to Neo4j
I have two kind of query 
the first one I start from a node such as 
match (n:student)
optional math (n)-[R:takes]-(n2:course)
return n, n2

The second kind of request: I have to start (point) from a relationship such as:
match ()-[R:takes]-()
optional match  ()-[R:takes]-(n:student)
optional match  (n:student)-[R:takes]-(p:course)
return n,p

but when I make this kind of query specially if I point to a relationship it takes a looooot of time :( so can I find another solution how to improve this type of query (with optional much)

thank for your help

Eve Freeman

unread,
Apr 12, 2018, 12:06:25 PM4/12/18
to ne...@googlegroups.com
In this case why do you need to start on the relationship? Can you start with student + relationship instead?

Can you explain in English what you’re trying to ask of be database?

Eve
Reply all
Reply to author
Forward
0 new messages