1

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");
chriszero
  • 1,311
  • 3
  • 13
  • 26
  • 1
    Are you opening a fresh database or a database which was created with a older-version (like 7.4)? Anyway so far everything looks correct to me, strange issue. – Gamlor Aug 04 '10 at 16:09
  • 1
    Database is created with the same version. Yes, it IS strange ^^ It's not time critical, but 5seconds are nearly an decade ;) – chriszero Aug 04 '10 at 17:08
  • 1
    One thing. The database is created with the .Net35 version of db4o, and it's read on a WindowsCE device running the Compactframework 2.0 – chriszero Aug 04 '10 at 17:22
  • 1
    How do you create and apply your configuration? A special GuidTypeHandler was introduced quite recently (before the version you are using) so the query should run indexed. Is the ._id field typed to Guid? – Carl Rosenberger Aug 04 '10 at 19:02
  • 1
    What happens if you run the query on the desktop? Does it still suggests to index the field? Is is still slow? Are you sure you use the same version (7.12.132) in the device? This version does support GUID indexes. Regarding accessing the db using CF 2.0 I don't see any problem (but it is not officially supported). – Vagaus Aug 04 '10 at 19:14
  • 1
    On the Desktop db4o complains only when I use the nativequeries. With Soda all is ok. – chriszero Aug 05 '10 at 11:36

0 Answers0