Linq to Db4o does not use an index

I am trying db4o and I have poor performance when using linq for db4o. (using 7.12)

Here is my configuration:

        var configuration = Db4oFactory.Configure();
        configuration.ObjectClass(typeof(MyTest)).ObjectField("MyInt").Indexed(true);

Here is the object I'm trying to save:

public class MyTest
{
    public int MyInt;
}

And here is my code using linq to db4o (response time 650 ms):

var test = (from c in repo.ObjectContainer.Query<MyTest>()
                        where c.MyInt == 6500
                        select c).FirstOrDefault();

And the same request using the built-in API (response time 28 ms):

var query = repo.ObjectContainer.Query();
query.Descend("MyTest");
query.Descend("MyInt").Constrain(6500)

Can someone tell me what happened with linq for db4o?

thanks

+5
source share
1 answer

I assume that the repo.ObjectContainer property is an instance of IObjectContainer, right?

The reason the index is not used is because you are using LINQ for objects, not db4o-LINQ-Provider.

IObjectContainer.Query() MyTest . LINQ to Object . , .

, db4o-LINQ-Provider. , Db4objects.Db4o.Linq.dll . IObjectContainer . :

    var test = (from MyTest c in repo.ObjectContainer
                    where c.MyInt == 6500
                    select c).FirstOrDefault();
+9

All Articles