views:

54

answers:

0

I have a simple object with a Guid as field public Guid _id, this field is indexed.

config.Common.ObjectClass(typeof(ConfigurableObject))
      .ObjectField("_id").Indexed(true);

When I open the databasefile in the ObjectManager Enterprise, it shows me that the field is indexed!

But my queries are damn slow. It takes up to 5!! seconds, there are only about 50 objects in the database.

Here's the query:

private void FindObject<T>(T toFind) where T : ConfigurableObject {
    var query = HeatingSystem.Instance.GetObjectContainer().Query();
    query.Constrain(typeof(T));
    query.Descend("_id").Constrain(toFind._id);

    IObjectSet result = query.Execute();

    /*IList<T> result = HeatingSystem.Instance.GetObjectContainer().Query<T>(
        delegate(T cobj) {
            return cobj._id == toFind.Guid;
        }
    );*/
}

Both, the native and the SODA query are slow.

When I add an

config.Common.Diagnostic.AddListener(
   new Db4objects.Db4o.Diagnostic.DiagnosticToConsole());

It says "Consider indexing fields that you query for."
and: "Query candidate set could not be loaded from a field index"

I'm using db4o 7.12.132.14217 for Compactframework 2.0

edit:
The Class with die Guid field:

public abstract class ConfigurableObject {
    private string _description;
    public Guid _id;
}

Here is the complete config

public static IEmbeddedConfiguration ConfigDb4O() { 
    IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
    config.Common.OptimizeNativeQueries = true;

    config.Common.ObjectClass(typeof(ConfigurableObject)).ObjectField("_id").Indexed(true);
    config.Common.ObjectClass(typeof(ConfigurableObject)).StoreTransientFields(false);

    return config;
}

I create / open the db with the following:

IObjectContainer db = Db4oEmbedded.OpenFile(ConfigDb4O(), "foo.db4o");