Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OrientDB slow write

Tags:

java

orientdb

OrientDB official site says:

On common hardware stores up to 150.000 documents per second, 10 billions of documents per day. Big Graphs are loaded in few milliseconds without executing costly JOIN such as the Relational DBMSs.

But, executing the following code shows that it's taking ~17000ms to insert 150000 simple documents.

import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.record.impl.ODocument;

public final class OrientDBTrial {

    public static void main(String[] args) {
        ODatabaseDocumentTx db = new ODatabaseDocumentTx("remote:localhost/foo");
        try {
            db.open("admin", "admin");

            long a = System.currentTimeMillis();
            for (int i = 1; i < 150000; ++i) {
                final ODocument foo = new ODocument("Foo");
                foo.field("code", i);
                foo.save();
            }
            long b = System.currentTimeMillis();
            System.out.println(b - a + "ms");

            for (ODocument doc : db.browseClass("Foo")) {
                doc.delete();
            }
        } finally {
            db.close();
        }
    }

}

My hardware:

  • Dell Optiplex 780
  • Intel(R) Core(TM)2 Duo CPU E7500 @ 2.93Ghz
  • 8GB RAM
  • Windows 7 64bits

What am I doing wrong?

Splitting the saves in 10 concurrent threads to minimize Java's overhead made it run in ~13000ms. Still far slower than what OrientDB front page says.

like image 510
Thiago Negri Avatar asked Aug 30 '12 21:08

Thiago Negri


2 Answers

You can achieve that by using 'Flat Database' and orientdb as an embedded library in java see more explained here http://code.google.com/p/orient/wiki/JavaAPI

what you use is server mode and it sends many requests to orientdb server, judging by your benchmark you got ~10 000 inserts per seconds which is not bad, e.g I think 10 000 requests/s is very good performance for any webserver (and orientdb server actually is a webserver and you can query it through http, but I think java is using binary mode)

like image 99
user781903 Avatar answered Sep 25 '22 21:09

user781903


The numbers from the OrientDB site are benchmarked for a local database (with no network overhead), so if you use a remote protocol, expect some delays.

As Krisztian pointed out, reuse objects if possible.

like image 43
gusto2 Avatar answered Sep 22 '22 21:09

gusto2