db4o allows to index fields to provide maximum querying performance. To request an index to be created, you would issue the following API method call in your global db4o configuration method db4o configuration method before you open an ObjectContainer/ObjectServer:
// assuming
class Foo{
String bar;
}
.NET: Db4oFactory.Configure().ObjectClass(typeof(Foo)).ObjectField("bar").Indexed(true);
If the configuration is set in this way, an index on the Foo#bar field will be created (if not present already) the next time you open an ObjectContainer/ObjectServer and you use the Foo class the first time in your applcation.
Contrary to all other configuration calls indexes - once created - will remain in a database even if the index configuration call is not issued before opening an ObjectContainer/ObjectServer.
To drop an index you would also issue a configuration call in your db4o configuration method:
.NET: Db4oFactory.Configure().ObjectClass(typeof(Foo)).ObjectField("bar").Indexed(false);
Actually dropping the index will take place the next time the respective class is used.db4o will tell you when it creates and drops indexes, if you choose a message level of 1 or higher:
.NET: Db4oFactory.Configure().MessageLevel(1);
For creating and dropping indexes on large amounts of objects there are two possible strategies:
For more information see Enable Field Indexes chapter.