apoc.periodic.truncate

Details

Syntax

apoc.periodic.truncate([ config ])

Description

Removes all entities (and optionally indexes and constraints) from the database using the apoc.periodic.iterate procedure.

Input arguments

Name

Type

Description

config

MAP

{ dropSchema = true :: BOOLEAN, batchSize = 10000 :: INTEGER, parallel = false :: BOOLEAN, retries = 0 :: INTEGER, batchMode = ""BATCH"" :: STRING, params = {} :: MAP, concurrency :: INTEGER, failedParams = -1 :: INTEGER, planner = ""DEFAULT"" :: [DEFAULT, COST, IDP, DP] }. The default is: {}.

Config parameters

The procedure supports the same configurations as the apoc.periodic.iterate procedure.

Moreover, it supports the following config parameters:

Config parameters
Name Type Default Description

dropSchema

BOOLEAN

true

drops all indexes and constraints

Example

Given this dataset:

CREATE (:Person {name: 'Alice'})-[:KNOWS]->(:Person {name: 'Bob'})
CREATE (:Person {name: 'Charlie'})

The following query removes all nodes and relationships from the database:

CALL apoc.periodic.truncate()
MATCH (n)
RETURN count(n)
Results
count(n)

0

After execution, the database contains no nodes or relationships, but any existing indexes and constraints are preserved.

To also drop all indexes and constraints in the same call, set dropSchema: true:

CALL apoc.periodic.truncate({dropSchema: true})

Deletion is performed in batches (default size 10000) via apoc.periodic.iterate, making it suitable for large graphs where a single MATCH (n) DETACH DELETE n would exhaust heap.