Issue of Performance in Generating our Graphs

Our Path Query:
UNWIND $start_node_hashes AS entityHash

  •       MATCH (startNode:Node {id:idValue})*
    
  •       CALL apoc.path.expand(startNode, "", "", 1, 1) YIELD path*
    
  •       WITH startNode, path, relationships(path) AS rels, nodes(path) AS nodes*
    
  •       RETURN startNode, path, rels, nodes*
    

Next,
We process the result records by reconstructing a graph manually in memory, record/path by path, and that consumes a lot of time. Basically, we do a merge for each node in the path and then bind them together. Thus, nodes and relationships are shared/reused.
Problem:
The underlying graph is very large, and this approach consumes a lot of time.
Question 1:
Is there a way to generate these subgraphs (the recombined entities) in a single step. Basically, extract the subgraph instead of nodes, paths, and relationships that then need to undergo the costly reconstruction effort? If possible, maybe for speed of analytics we project these into an in-memory graph.
Question 2:
Perhaps doing all this in a Neo4j Plugin? This would avoid the repetitive execution of merge commands to create the new subgraph.

What are you reconstructing when you have a subgraph you are getting from apoc.path.expand?

Anyway, cyber is good for finding and processing paths. It is not very good on subgraphs. A custom plugin is a good solution to investigate, as you will not be getting the paths, bringing back to your client, processing them, and then sending the updates back to the server. It will all be done on the neo4j server itself.

Thats what I thought.. See.. you.. did a good job teaching me.. :).. i just had to run this by someone that actually knows what they are doing.. Thanks man

1 Like