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

Big performance penalty with query constrains

Last post 09-04-2008, 02:48 PM by ErikNRC. 2 replies.
Sort Posts: Previous Next
  •  09-03-2008, 12:46 PM 50889

    Big performance penalty with query constrains

    I did any performance tests on my system and I have to notice that all queries with String constrains are very slow.
    For the whole example is the index true;
     

    In my testcase an normal query like:

            Query query=db.query();
            query.constrain(Personal.class);
            query.descend("name").constrain("Mustermann");

    deliver this results.

        Benchmark 6  (Checksumme: 189)--> 342 ms        // first round and open DB, all other rounds run with opened DB
        Benchmark 6  (Checksumme: 189)--> 76 ms
        Benchmark 6  (Checksumme: 189)--> 95 ms
        Benchmark 6  (Checksumme: 189)--> 16 ms
        Benchmark 6  (Checksumme: 189)--> 15 ms
        Benchmark 6  (Checksumme: 189)--> 74 ms
        Benchmark 6  (Checksumme: 189)--> 21 ms

    But this query is much slower as befor.

        Query query=db.query();
        query.constrain(Personal.class);
        query.descend("name").constrain("Mustermann").startsWith(true);

    No matter which string constraint I have used, the query is slow.

        Benchmark 6  (Checksumme: 201)--> 550 ms       // first round and open DB, all other rounds run with opened DB
        Benchmark 6  (Checksumme: 201)--> 207 ms
        Benchmark 6  (Checksumme: 201)--> 207 ms
        Benchmark 6  (Checksumme: 201)--> 203 ms
        Benchmark 6  (Checksumme: 201)--> 206 ms
        Benchmark 6  (Checksumme: 201)--> 217 ms
        Benchmark 6  (Checksumme: 201)--> 203 ms

    Why are queries with (startswith, endswith, contains, like, ...) so much slower????


    Can anybody give an advice?  


    Germany
  •  09-04-2008, 07:57 AM 50895 in reply to 50889

    Re: Big performance penalty with query constrains

    At an other query the penaty is much bigger.

    without startswith(false)

        Benchmark 7  (Checksumme: 3)--> 80 ms
        Benchmark 7  (Checksumme: 3)--> 3 ms
        Benchmark 7  (Checksumme: 3)--> 3 ms
        Benchmark 7  (Checksumme: 3)--> 2 ms
        Benchmark 7  (Checksumme: 3)--> 3 ms
        Benchmark 7  (Checksumme: 3)--> 2 ms
        Benchmark 7  (Checksumme: 3)--> 2 ms

    with startswith(false); (same objectcount) 

        Benchmark 7  (Checksumme: 3)--> 668 ms
        Benchmark 7  (Checksumme: 3)--> 586 ms
        Benchmark 7  (Checksumme: 3)--> 582 ms
        Benchmark 7  (Checksumme: 3)--> 580 ms
        Benchmark 7  (Checksumme: 3)--> 574 ms
        Benchmark 7  (Checksumme: 3)--> 569 ms
        Benchmark 7  (Checksumme: 3)--> 745 ms

    It cant be! I look in to the source code and find in the db4o-7.4\src\db4oj\core\src\com\db4o\internal\query\processor\QEStringCmp file the following line. Should this mean that all string comperators dont support an index?

    public boolean supportsIndex(){
            return false;
    }


     


    Germany
  •  09-04-2008, 02:48 PM 50900 in reply to 50889

    Re: Big performance penalty with query constrains

    Origon45:

    Why are queries with (startswith, endswith, contains, like, ...) so much slower????
    Can anybody give an advice?  

    More than likely, these queries cannot use the index. The db needs to walk through all the objects and evaluate your predicate against them.
    I'm not sure that an index for these queries makes any sense. If you give more details about your application maybe there are other ways to solve the problem?

    Erik.

     

View as RSS news feed in XML