# Strategy for matching 6 million nodes

**URL:** <https://community.neo4j.com/t/strategy-for-matching-6-million-nodes/54254>\
**Category:** Cypher\
**Created:** [April 1, 2022, 7:00am UTC](https://community.neo4j.com/t/strategy-for-matching-6-million-nodes/54254 "2022-04-01T07:00:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bent.s.lund](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/bent.s.lund/32/18066_2.png) [@bent.s.lund](https://community.neo4j.com/u/bent.s.lund)\
**Post date:** [April 1, 2022, 7:00am UTC](https://community.neo4j.com/t/strategy-for-matching-6-million-nodes/54254/1 "2022-04-01T07:00:40Z")

</div>

Hi,

I have 6 mill nodes "Equipment" that I want to relate to 60.000 node "Product" by matching on 2 properties (.Manufacturer and .Model) that are common on both node types. Properties are indexed on both node types

This is time-consuming and prone to cause out-of-memory errors, are there any tricks I can apply?  
I have tried  
CALL apoc.periodic.iterate("  
....  
",{batchSize:10000, parallel:false})

---

<div class="post-metadata">

**Author:** ![koji](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/koji/32/27564_2.png) [@koji](https://community.neo4j.com/u/koji)\
**Post date:** [April 1, 2022, 10:22pm UTC](https://community.neo4j.com/t/strategy-for-matching-6-million-nodes/54254/2 "2022-04-01T22:22:35Z")

</div>

Hi @bent.s.lund

The first step is to create indexes like this.

```auto
CREATE INDEX equipment_index FOR (n:Equipment) ON (n.Manufacturer, n.Model);
CREATE INDEX product_index FOR (n:Product) ON (n.Manufacturer, n.Model);

```

The "CALL apoc.periodic.iterate(" works fine even for nearly 100 million data.

---

<div class="post-metadata">

**Author:** ![bent.s.lund](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/bent.s.lund/32/18066_2.png) [@bent.s.lund](https://community.neo4j.com/u/bent.s.lund)\
**Post date:** [April 2, 2022, 9:29am UTC](https://community.neo4j.com/t/strategy-for-matching-6-million-nodes/54254/3 "2022-04-02T09:29:40Z")

</div>

Thanks koji,  
you confirmed that my approach on this was correct! I must have done something wrong maybe with the indexes - when I tried again I was able to match and create relations between nodes.  
Thanks for your help!
