cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Tunning a filtering relationships query

I'm using Neo4j 3.5 enterprise version,
and I profiling the cypher below:

MATCH (J:Host) WHERE J.Status = "running" AND not (J)-->(:Ipv4 {Ipv4: "xxx"}) AND (J)<--(:Cluster {Name: "yyy"}) return J

The result of profiling looks like:


It seems there are lots of db hits and the cypher cost multiple hundreds ms.
What can I do to tunning the query? I can't think of a better cypher..

2 REPLIES 2

Bennu
Graph Fellow

Hi @SgtDaJim ,

This should be bit better

MATCH (J:Host)<--(:Cluster {Name: "yyy"}) 
WHERE J.Status = "running" 
with J where not (J)-->(:Ipv4 {Ipv4: "xxx"}) 
return J

Lemme know,

Bennu

Benoit_d
Graph Buddy

giving @Bennu right.

Especially because property "Name" on Cluster and property "Ipv4" on Ipv4 are both indexed as unique, querying on them will reduce the hits at the quickest.

Therefore on an other way would be:

MATCH (:Ipv4 {Ipv4: "xxx"})<--(rejected:Host)-->(:Cluster {Name: "yyy"})-->(J:Host)
WHERE J.Status = "running" 
return J

with this you get the "Host" around the named cluster separated in 2 parts: those which are aside the Ipv4 and the other.

We are curious about the profiling of Bennu's proposition and mine. Please post results.