Skip to content

Performance Tuning Graph

azzazzel edited this page Jan 4, 2013 · 4 revisions

Guide to improve performance of Graph Database

<wiki:toc max_depth="4" />

This guide is specific for the Graph Database. Please be sure to read the generic guide to the Performance-Tuning.

Massive Insertion

See Generic improvement on massive insertion.

Reduce vertex objects

You can avoid the creation of a new ODocument for each new vertex by reusing it with ODocument.reset() method that clears the instance making it ready for a new insert operation. Bear in mind that you will need to assign the document with the proper class after resetting as it is done in the code below.

NOTE: This trick works ONLY IN NON-TRANSACTIONAL contexts, because during transactions the documents could be kept in memory until commit.

Example:

    db.declareIntent( new OIntentMassiveInsert() );
    
    ODocument doc = db.createVertex("myVertex");
    for( int i = 0; i < 1000000; ++i ){
      doc.reset();
      doc.setClassName("myVertex");
      doc.field("id", i);
      doc.field("name", "Jason");
      doc.save();
    }
    
    db.declareIntent( null );

Cache management

Graph Database, by default, caches the most used elements. For massive insertion is strongly suggested to disable cache to avoid to keep all the element in memory. Massive Insert Intent automatically sets it to false.

    graph.setRetainObjects(false);
Clone this wiki locally