apoc.nodes.delete

This procedure is deprecated. Use Cypher’s CALL subqueries in transactions instead.

Details

Syntax

apoc.nodes.delete(nodes, batchSize) :: (value)

Description

Deletes all NODE values with the given ids.

Input arguments

Name

Type

Description

nodes

ANY

The nodes to be deleted. Nodes can be of type STRING (elementId()), INTEGER (id()), NODE, or LIST<STRING | INTEGER | NODE>.

batchSize

INTEGER

The number of node values to delete in a single batch.

Return arguments

Name

Type

Description

value

INTEGER

The number of deleted nodes.

Prior to the release of APOC 2025.07, this procedure was restricted on on-premise instances. To use it on an older version, it must be unrestricted. For more details, see Installation → Load and unrestrict.

Usage Examples

The examples in this section are based on the following graph:

CREATE (:Student {name: 'Alice', score: 71});
CREATE (:Student {name: 'Mark', score: 95});
CREATE (:Student {name: 'Andrea', score: 86});

The below examples show how to delete nodes in different transaction batches using Cypher and APOC:

apoc.nodes.delete
MATCH (n:Student)
WITH collect(n) AS nodes
CALL apoc.nodes.delete(nodes, 2)
YIELD value
RETURN value
Cypher’s CALL {…​} IN TRANSACTIONS
MATCH (n:Student)
CALL (n) {
    DETACH DELETE n
} IN TRANSACTIONS OF 2 ROWS
RETURN count(n) AS value
Results
value

3