cypher - Single match query request vs Multiple match query request in Neo4J -


which better between doing single match query request vs multiple match query requests in neo4j? (note: read (match/optional match) cypher here, no write operation cypher concerned).

in case, using single match query request make cypher end many with statements , cypher big, i'm worry cypher readibility.

on other side, using multiple match query requests, worry performance because there multiple database hits.

so can give me thought this? if should after performance, should go single query request approach?

fyi, i'm using neo4j v2.2.

update:

an example of single match query:

match (a:a {id: {id} }), (b:b {id: {id2} })  a, b  match (b)-[:r1]->(x:x) optional match (y:y)-[:r2]->(x)  a, b, count(y) c  optional match (a)-[r3:r3]->(b)  a, b, c, count(r3) > 0 d;  ... // match/optional match & statements  return a, b, c, d, ...; 

if using multiple query request:

// query 1 match (a:a {id: {id} }), (b:b {id: {id2} }) return a, b;  // query 2 match (b:b {id: {id}})-[:r1]->(x:x) optional match (y:y)-[:r2]->(x) return count(y);  // query 3 match (a:a {id: {id}})-[r3:r3]->(b:b {id: {id2}}) return count(r3) > 0; 

you can use newlines (say, after commas) , indentation make long match statement readable.

on other hand, breaking long match statement multiple statements not change neo4j behavior or performance (since cypher mechanism job of optimizing). sure, can use profile or explain compare behavior of alternate versions of query.

but there big caveat. single match statement (that involves relationships) automatically filter out duplicate relationships; want. if break multiple match statements such not relationships matched in same statement, lose filtering. see this question more info.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -