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.

Optimizing code within apoc.periodic.iterate

Is there anything I can speeden this below code:

CALL apoc.periodic.iterate("MATCH (a:alias) RETURN a",
"Match 
path=((a:alias) -- (c1:citation) -[p1]-> (t:BIOTERM) <-[p2]- (c2:citation) -- (b:alias))
WHERE id(a) < id(b) AND id(c1) <> id(c2)
With a, b, p1, p2, 2 as precision
 WITH a, b, p1, p2, 10^precision as factor
Create (a)-[e:through_topic]->(b)
Set e.weight= round(factor* (1/(2+p1.weight+p2.weight))) / factor", {batchSize:1000}) YIELD batches, total, errorMessages

which runs for 1 or 2 ms for one alias. Attaching PROFILE of the code here.

Thanks,

1 REPLY 1

Hi, Without knowing more of the graph design, and query goals, here are some thoughts

Specify the direction on all relationships, if you can

also on this pattern
(a:alias) -- (c1:citation)
I imagine specifying the relationship type(s) to explore in the query might help, especially after you have added some of the :through_topic relationships, between alias nodes

Just a note: It won't change the dbhits, and possibly you are not posting your actual cypher, but in this example, all of the precision/factor references look like a really complicated way of writing a constant value of 100 in the weight formula..