フィールドとして Guid を持つ単純なオブジェクトがありpublic Guid _id
、このフィールドにはインデックスが付けられています。
config.Common.ObjectClass(typeof(ConfigurableObject))
.ObjectField("_id").Indexed(true);
ObjectManager Enterprise でデータベース ファイルを開くと、フィールドがインデックス化されていることがわかります。
しかし、私のクエリは非常に遅いです。5までかかります!! 数秒後、データベースには約 50 個のオブジェクトしかありません。
クエリは次のとおりです。
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;
}
);*/
}
ネイティブ クエリと SODA クエリの両方が低速です。
追加すると
config.Common.Diagnostic.AddListener(
new Db4objects.Db4o.Diagnostic.DiagnosticToConsole());
「クエリを実行するフィールドのインデックス作成を検討してください」と書かれています。
および: 「クエリ候補セットをフィールド インデックスから読み込めませんでした」
Compactframework 2.0 に db4o 7.12.132.14217 を使用しています
編集:
Die Guid フィールドを持つクラス:
public abstract class ConfigurableObject {
private string _description;
public Guid _id;
}
ここに完全な設定があります
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;
}
次のようにデータベースを作成/開きます。
IObjectContainer db = Db4oEmbedded.OpenFile(ConfigDb4O(), "foo.db4o");