Menu

NeoDatis 4x faster than db4o

akahanek
2008-11-30
2013-05-29
  • akahanek

    akahanek - 2008-11-30

    Hi,
    I did a simple test with storing and retrieving about 30000 simple objects into a database. Exactly the same model and code with db4o and NeoDatis. What a big surprise to me, that NeoDatis was almost 4x faster than db4o!

    One answer could be, that NeoDatis has a better design.

    Or another one could be, that db4o is more complex and takes care of some features that could take some overhead and makes the system slower. What is the right interpretation?

    In any case - keep up the good work!

    Ales

     
    • Olivier

      Olivier - 2008-11-30

      Hi Ales!

      This is good to hear that.

      Are you using NeoDatis on Java or .Net? In local or client server mode?

      I can't really answer your question about why as I don't know the internal design of DB4O. About features that Db4O could execute and not NeoDatis, this is possible too, but again we would have to check that.

      Anyway, we always use Db4O for our performance tests and always try to be faster.

      Thanks Ales,
      Olivier 

       
      • akahanek

        akahanek - 2008-12-02

        Hi Olivier,
        I am using Java in local mode. I have looked closely to the test and now I have to say, that there was a small mistake in my code. Yes, it is true, that NeoDatis is faster to insert those 30000 objects than db4o, but not in retrieving them from db. When I wrote my query, I did this:

        Objects set = db.getObjects(new SimpleNativeQuery() {
                    public boolean match(ICompany c){
                        return c.getRevenue() > 5000;
                    }
                });

        This query returned 0 objects and I did not check that. Later I noticed it and realized, that I should use the Company class instead of the ICompany interface. This mistake was caused by the fact, that db4o allows uning interfaces in the queries and NeoDatis seems not.

        So I run this query:

        Objects set = db.getObjects(new SimpleNativeQuery() {
                    public boolean match(Company c){
                        return c.getRevenue() > 5000;
                    }
                });

        and waited quite long for the results. I debugged the code and found something like this in the call stack:

        org.neodatis.odb.core.query.execution.GenericQueryExecutor.executeFullScan(GenericQueryExecutor.java:329)

        That could be the problem as I think no index is used there. How can I force NeoDatis to use an index or can I do something else to speed this up?

        Thanks for any comments.
        Ales

         
    • Olivier

      Olivier - 2008-12-03

      Hi Ales,

      NativeQueries do not use indexes yet (they always do a full scan :-( ). You will get a better performance with CriteriaQuery.

      Try this:

      Objects set = db.getObjects( new CriteriaQuery(Company.class, Where.gt("revenue", 5000)) );

      Criteria queries are much more efficient as they don't need to create objects to check the 'where' (only create object instance when it is part of the result) and they use the indexes previously defined for the class.

      Let me know if you have better results.

      Thanks,
      Olivier.

       
      • akahanek

        akahanek - 2008-12-03

        Thanks for clarification. I´ll give it a try, but I would like to avoid text based queries and use as much as possible native queries due to compile time check and refactoring.

        Ales

         
        • Olivier

          Olivier - 2008-12-03

          Hi Ales!

          You are right, NativeQueries have this advantage. I know DB4O can execute NativeQueries with indexes in __some__ cases. We are working in that.

          Thanks
          Olivier

           

Log in to post a comment.