cancel
Showing results for 
Search instead for 
Did you mean: 

How to mark all nodes and relationships faster

busymo16
Ninja
Ninja

Hi everyone,

i am currently using this query to mark all the nodes and relationships in my graph:

CALL apoc.periodic.iterate(
"
cypher runtime=slotted
MATCH (n)-[r]->(m)
RETURN n, r, m
",
"
SET n.fullLoadDelete = 1,
r.fullLoadDelete = 1,
m.fullLoadDelete = 1
", {batchSize: 10000, parallel: false}
);

Is there any apoc procedure to mark it in a faster way while using less memory? Only to add (mark) to all nodes and relationships a property. Then also to delete, the nodes and relationships, with this property. Thanks!

1 REPLY 1

glilienfield
Ninja
Ninja

In your approach, you could be setting the same node multiple times, since it will show up multiple times if it has multiple relationships in/out.  Since you are setting the same property name on nodes and relationships, you could use the following query. See if it is any faster. 

CALL apoc.periodic.iterate(
    "
        match(n)
        return n
        union
        match()-[n]-()
        return n
    ",
    "
        SET n.fullLoadDelete = 1
    ", {batchSize: 10000, parallel: false}
);