Improve match of two sets of nodes

Hello,
I have two labels (commits and users).
In the commits I have the ID of the committer as Int (committer-id).
I want to create a simple relationship between the committer and the user (u.id).
My solution looks like this:

match(c:commits)
with c
match(u:users)
where c.committer_id = u.id
create(c)-[:committer]->(u) 

My current problem is that is takes a long time to create this relationship.
I added an index the committer_id, but it didn't improve my query.
Any Idea of improvements?

Constraints:

Settings:

dbms.memory.heap.initial_size=8G
dbms.memory.heap.max_size=8G
dbms.memory.pagecache.size=5G

Hello @JuSte94 and welcome to the Neo4j community :slight_smile:

You should try with the apoc.periodic.iterate() function in the APOC plugin:

CALL apoc.periodic.iterate(
  "MATCH (u:users) MATCH (c:commits) WHERE c.committer_id = u.id RETURN c, u",
  "CREATE (c)-[:committer]->(u)",
  {batchSize: 10000}
)

Regards,
Cobra

1 Like

Hey @Cobra

thank you. Worked well :slight_smile:

1 Like