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.

How to reuse the same execution plan for similar structure?

Is it possible to reuse the same execution plan for similar pattern? In my example I have a structure the looks like this:

Essentially, for each time I always start from node (A) and traverse and retrieve the node (D) in different combinations based on the relationship range that I have specified from (A-B) and (C-D) on the same path. The structure of number of steps between (A) and (D) will never change but will add more nodes spanning outwards from (A). The relationship between (C-D) will always be either REL_X, REL_Y, or REL_Z and the relationship between (B-C) will always be one of 20 different relationship "Q" so that there only exists one unique "Q" for each path between (A)--->(B)-[Q]->(C).

// Example matching
(a:A)
// (B1) will fetch D1 and D2 from C1 in this example
(a)-[:REL_B1]->(b1:B)
(b1)-[:REL_C1]->(c1:C)
(c1)-[:REL_X]->(d1:D)
(c1)-[:REL_Y]->(d2:D)
// (B2) will only fetch D3 from C1 in this example
(a)-[:REL_B2]->(b2:B)
(b2)-[:REL_C2]->(c2:C)
(c2)-[:REL_X]->(d3:D)

How can I cache or hint to neo4j that I want to reuse the same execution plan everytime and only through parameters change the relationship range? It seems highly inefficient right now to perform the same query multiple times and each time recalculate the plan when the general path is always known beforehand

0 REPLIES 0