I am trying to merge duplicate nodes using this ( A, B ,C values are just for explanation)
CALL apoc.periodic.iterate("match (a1:Person) where a1.registryMouhafaza='A' and a1.registryKadaa='B' and a1.registryTown='C' with a1.duplicateField as dup , collect(a1) as nodes where size(nodes)>1 return nodes","CALL apoc.refactor.mergeNodes(nodes,{ properties:'combine', mergeRels:true}) YIELD node set node.id=randomUUID()",{batchSize:5000})
The data that needs to be worked on is only about 300 nodes. The query gets stuck . In the transactions i see that there 2 are transactions and one is blocking the other
|"CALL apoc.periodic.iterate("match (a1:Person) where a1.registryMouhafaza='A' and a1.registryKadaa='B' and a1.registryTown='C' with a1.duplicateField as dup , collect(a1) as nodes where size(nodes)>1 return nodes","CALL apoc.refactor.mergeNodes(nodes,{ properties:'combine', mergeRels:true}) YIELD node set node.id=randomUUID()",{batchSize:5000})"| "Blocked by: [neo4j-transaction-145]"
where neo4j-transaction-145 is the following
"UNWIND $_batch AS _batch WITH _batch.nodes AS nodes CALL apoc.refactor.mergeNodes(nodes,{ properties:'combine', mergeRels:true}) YIELD node set node.id=randomUUID()"
However if i run it without using iterate it works fine and completes within seconds
match (a1:Person) where a1.registryMouhafaza='A' and a1.registryKadaa='B' and a1.registryTown='C' with a1.duplicateField as dup , collect(a1) as nodes where size(nodes)>1 with nodes CALL apoc.refactor.mergeNodes(nodes,{ properties:'combine', mergeRels:true}) YIELD node set node.id=randomUUID()
I have a range index on registryMouhafaza,registryKadaa,registryTown and on duplicateField
I need to run this query on multiple combinations of registryMouhafaza,registryKadaa,registryTown, where in some combinations, the data would be thousands, so I don't want to have to drop the iterate and risk getting Java Heap issues