apoc.periodic.commit
Syntax |
|
||
Description |
Runs the given statement in separate batched transactions. |
||
Input arguments |
Name |
Type |
Description |
|
|
The Cypher statement to run. |
|
|
|
The parameters for the given Cypher statement. The default is: |
|
Return arguments |
Name |
Type |
Description |
|
|
The total number of updates. |
|
|
|
The total number of executions. |
|
|
|
The total time taken in nanoseconds. |
|
|
|
The number of run batches. |
|
|
|
The number of failed batches. |
|
|
|
Errors returned from the failed batches. |
|
|
|
The number of failed commits. |
|
|
|
Errors returned from the failed commits. |
|
|
|
If the job was terminated. |
Usage Examples
The examples in this section are based on the following sample graph:
WITH ["London", "Manchester", "Cardiff", "Birmingham", "Coventry", "Edinburgh"] AS cities
UNWIND range(1, 10000) AS id
MERGE (p:Person {id: id})
WITH cities, p, toInteger(rand() * size(cities)) AS index
SET p.city = cities[index];
If we want to convert the city
property to a node, we can do this in batches of 1,000, by running the following query:
CALL apoc.periodic.commit(
"MATCH (person:Person)
WHERE person.city IS NOT NULL
WITH person limit $limit
MERGE (city:City {name:person.city})
MERGE (person)-[:LIVES_IN]->(city)
REMOVE person.city
RETURN count(*)",
{limit:1000});
updates | executions | runtime | batches | failedBatches | batchErrors | failedCommits | commitErrors | wasTerminated |
---|---|---|---|---|---|---|---|---|
10000 |
10 |
0 |
11 |
0 |
{} |
0 |
{} |
FALSE |
We can check that the refactoring has been done by running the following query:
MATCH (p:Person)
RETURN p.city IS NOT NULL as exists, count(*);
exists | count(*) |
---|---|
FALSE |
10000 |