cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

Save data with spring take too much time

tomer_bar
Node Link

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

3 REPLIES 3

gerrit_meier
Neo4j
Neo4j

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

tomer_bar
Node Link
<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>

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, ......