db4o Developer Community

db4o open source object database, native to Java and .NET
Welcome to db4o Developer Community Sign in | Join
in Search
More Search Options

Db4o performance

Last post 08-28-2008, 03:27 PM by error0. 2 replies.
Sort Posts: Previous Next
  •  08-27-2008, 03:57 PM 50803

    Db4o performance

    Hello!

    This is my problem:

    1. I create a new empty database
    2. then I put 10.000 objects and this takes about 2xx ms
    3. commit
    4. I read 100 objects from the database and this takes about 42xx ms (4 seconds and 2xx ms)

    Is this a normal value? It seems to me too big. Can you tell me if i'm doing something wrong, or how to speed up the reads?

    Thanks.

     

    I run this program on an high performance laptop (3GB RAM, 2.2Ghz dual core ...)

    I use a simple POJO object to be persisted: only 1 private field (int) .

    This is the code i use to execute this very simple test:

    public static void main(String[] args) {
            new File("database_file").delete();
            ObjectContainer db = Db4o.openFile("database_file");
            long start = System.currentTimeMillis();
            for (int i = 0; i < 10000; i++) {
                db.store(new Number(i));
            }   
            System.out.println("time: " + (System.currentTimeMillis()-start));
            db.commit();
            System.out.println("size: " + db.queryByExample(new Number()).size());
            start = System.currentTimeMillis();
            for (int i = 0; i < 100; i++) {
                db.queryByExample(new Number(i));
            }
            System.out.println("time: " + (System.currentTimeMillis()-start));
            db.close();
        }

     

  •  08-27-2008, 04:18 PM 50804 in reply to 50803

    Re: Db4o performance

    You should index the integer field of your Number class.  The indexing reference document discusses this and provides examples.

    HTH,

    Brett

  •  08-28-2008, 03:27 PM 50818 in reply to 50804

    Re: Db4o performance

    thanks. The difference is really huge. About 2 order of magnitude faster. Now it takes about 70 ms.
View as RSS news feed in XML