save method of CRUDRepository is very slow?

后端 未结 4 1089
滥情空心
滥情空心 2020-12-15 13:27

i want to store some data in my neo4j database. i use spring-data-neo4j for that.

my code is like the follow:

    for (int i = 0; i < newRisks.siz         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 14:19

    I think I've found a solution:

    I tried the same insert using the nativ neo4j java API:

    GraphDatabaseService graphDb;
    Node firstNode;
    Node secondNode;
    Relationship relationship;
    
    graphDb = new EmbeddedGraphDatabase(DB_PATH);
    Transaction tx = graphDb.beginTx();
    
    try {
        firstNode = graphDb.createNode();
        firstNode.setProperty( "name", "Root" );
    
        for (int i = 0; i < 60000; i++) {
            secondNode = graphDb.createNode();
            secondNode.setProperty( "name", "risk " + (i+1));
    
            relationship = firstNode.createRelationshipTo( secondNode, RelTypes.CHILD );
        }
        tx.success();
    }
    finally {
        tx.finish();
        graphDb.shutdown();
    }
    

    the result: after some sconds, the database is filled with risks.

    Maybe the reflections slow down this routine with spring-data-neo4j. @Michael Hunger says somthing like that in his book GoodRelationships, thanks for that tip.

提交回复
热议问题