# Save data with spring take too much time

**URL:** <https://community.neo4j.com/t/save-data-with-spring-take-too-much-time/29405>\
**Category:** Spring Data Neo4j & Neo4j-OGM\
**Created:** [November 21, 2020, 12:27pm UTC](https://community.neo4j.com/t/save-data-with-spring-take-too-much-time/29405 "2020-11-21T12:27:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomer.bar](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tomer.bar/32/11699_2.png) [@tomer.bar](https://community.neo4j.com/u/tomer.bar)\
**Post date:** [November 21, 2020, 12:27pm UTC](https://community.neo4j.com/t/save-data-with-spring-take-too-much-time/29405/1 "2020-11-21T12:27:48Z")

</div>

Im using neo4j spring data for save node,by using saveall method based on org.springframework.data.neo4j.repository.Neo4jRepository  
Im trying to work with batch of 2000 entity per each saveall operation ,for the firsts operations it take aroung to 10 second - and be come more slower - the worst case is 10 min for 2000 entities when in neo4j found 200,000 nodes without any relation

Tnx in advance

---

<div class="post-metadata">

**Author:** ![gerrit.meier](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/gerrit.meier/32/27374_2.png) [@gerrit.meier](https://community.neo4j.com/u/gerrit.meier)\
**Post date:** [November 23, 2020, 10:34am UTC](https://community.neo4j.com/t/save-data-with-spring-take-too-much-time/29405/2 "2020-11-23T10:34:13Z")

</div>

Could you please tell me which version of Spring Data Neo4j you are running?

---

<div class="post-metadata">

**Author:** ![tomer.bar](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tomer.bar/32/11699_2.png) [@tomer.bar](https://community.neo4j.com/u/tomer.bar)\
**Post date:** [November 24, 2020, 11:09am UTC](https://community.neo4j.com/t/save-data-with-spring-take-too-much-time/29405/3 "2020-11-24T11:09:38Z")

</div>

```auto
<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.6.RELEASE</version>
        <relativePath/>
    </parent>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-neo4j -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-neo4j</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

```

---

<div class="post-metadata">

**Author:** ![stefan.lankester](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stefan.lankester/32/18772_2.png) [@stefan.lankester](https://community.neo4j.com/u/stefan.lankester)\
**Post date:** [September 16, 2021, 2:25am UTC](https://community.neo4j.com/t/save-data-with-spring-take-too-much-time/29405/4 "2021-09-16T02:25:55Z")

</div>

I expect that you might have a single Node entity class in your Spring Boot solution and that your are using dynamic labels (@Labels())

I expect that saveall uses a merge for each node that it creates. Creating an index on id will solve your performance problemen. Performance now decreases each time that you call saveall, (Also see @Properties(prefix="node",delimeter="\_", allowCast=true for creating a dynamic properties collection)

Node is here the Node entity class. (Issue that i see in Neo4j browser is that is shows total count for Node (my entity class) and the totals for each dynamic label,

CREATE INDEX ON :Node(id)

Creating the index solved the performance issue for me. Saving 5300 Nodes and about 3000 Edges now each time in \< 2s. Without the index 10s increasing after each saveall 20s, 35s, ......
