I've gone through Wes Freeman's blogpost<http://wes.skeweredrook.com/pragmatic-cypher-optimization-2-0-m06/>on Cypher optimizations and Mark Needham's blogpost<http://www.markhneedham.com/blog/2013/11/08/neo4j-2-0-0-m06-applying-wes-freemans-cypher-optimisation-tricks/>on applying them, and they talked about avoiding Cartesian products when constructing cypher queries. I have some serious questions regarding when the need arises to absolutely use cartesian products as and when we are left no choice. But first, i'd like to post a cypher query and figure out whether it is susceptible to Cartesian products or not.
Here's the query: MATCH (n1:Node_Type_1) WHERE n1.property="value" WITH n1 MATCH > n1--(n2:Node_Type_2) WHERE n2.property="value" WITH n2 MATCH > (n3:Node_Type_3) WHERE f.property="value" WITH n2,n3 MATCH > n2--(n4:Node_Type_4)--n3 RETURN n4.name, n3.name, n2.name; Here is the graphical representation of what i'm trying to do with the query: (n1) > WITH n1 > (n1) -- (n2) > WITH n2 > (n3) > WITH n2, n3 > (n2) -- (n4) -- (n3) > RETURN n2, n4, n3 My understanding is that right after "WITH n2" since the following MATCH clause has nothing to do with n2, and seems to be simply passing on n2 to the next MATCH clause using "WITH n2,n3", it WILL form a Cartesian product. Am i right? I'm asking whether i'm, right or wrong since based on that I know I can take certain steps without having to bother you guys! But I do have a follow up question to ask if I am right about my assessment of cypher Cartesian products in this particular case. Thanks and cheers!! Arijeet Mukherjee -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
