# How to bulk delete selected nodes from a list

**URL:** <https://community.neo4j.com/t/how-to-bulk-delete-selected-nodes-from-a-list/20793>\
**Category:** Cypher\
**Created:** [June 30, 2020, 4:47am UTC](https://community.neo4j.com/t/how-to-bulk-delete-selected-nodes-from-a-list/20793 "2020-06-30T04:47:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarendran.vivekanand](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tarendran.vivekanand/32/3909_2.png) [@tarendran.vivekanand](https://community.neo4j.com/u/tarendran.vivekanand)\
**Post date:** [June 30, 2020, 4:47am UTC](https://community.neo4j.com/t/how-to-bulk-delete-selected-nodes-from-a-list/20793/1 "2020-06-30T04:47:16Z")

</div>

What would be the best way to delete 1000+ or 100000+ selected nodes? Should I use `UNWIND` and `MATCH` to get a list of the nodes I want to delete then detach delete them.

```auto
UNWIND $data as delete
MATCH (c:Car)
WHERE c.model = delete.model
DETACH DELETE

```

This is very slow. Is there a better way?

---

<div class="post-metadata">

**Author:** ![Cobra](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/cobra/32/35243_2.png) [@Cobra](https://community.neo4j.com/u/Cobra)\
**Post date:** [June 30, 2020, 8:14am UTC](https://community.neo4j.com/t/how-to-bulk-delete-selected-nodes-from-a-list/20793/2 "2020-06-30T08:14:15Z")

</div>

Hello @tarendran.vivekanand 🙂

You can pass for example ids you want to delete in the `data`, but if you want to keep your original request, you can still use `apoc.periodic.iterate()` 🙂

```auto
CALL apoc.periodic.iterate('MATCH (c:Car) WHERE c.model IN data RETURN c', 'DETACH DELETE c', {batchSize:1000, params:{data:$data}})

```

Regards,  
Cobra

---

<div class="post-metadata">

**Author:** ![tarendran.vivekanand](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tarendran.vivekanand/32/3909_2.png) [@tarendran.vivekanand](https://community.neo4j.com/u/tarendran.vivekanand)\
**Post date:** [June 30, 2020, 9:11am UTC](https://community.neo4j.com/t/how-to-bulk-delete-selected-nodes-from-a-list/20793/3 "2020-06-30T09:11:51Z")

</div>

Hello @Cobra 🙂  
Thanks for the advice but how do you determine the batchSize number of 1000. Is this arbitrary or is there some formula to this?

---

<div class="post-metadata">

**Author:** ![Cobra](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/cobra/32/35243_2.png) [@Cobra](https://community.neo4j.com/u/Cobra)\
**Post date:** [June 30, 2020, 9:13am UTC](https://community.neo4j.com/t/how-to-bulk-delete-selected-nodes-from-a-list/20793/4 "2020-06-30T09:13:26Z")

</div>

It depends of the power of your computer 🙂, by default I use 1000, but you can try other values between 100 and 10 000 🙂
