Currently, db4o does not allow indexing on the contents of collections. What object databases do allow indexing of any individual field in the database?
Example:
class RootClass
{
string thisIsIndexed; // Field can be indexed for quick searching.
IList<SubClass> contentsNotIndexed = new ArrayList(); // Creates a 1-to-many relationship.
}
class SubClass
{
string thisIsNotIndexed; // Field cannot be indexed.
}
For db4o to search by field "thisIsNotIndexed", it would have to load the complete object into memory, then use LINQ-to-Objects to scan through the field. This is slow, as it means you would potentially have to load the entire database into RAM to do a search. The way to work around this is to have all of the fields you want to search by in the root object, however, this seems like an artificial limitation.
Are there any object databases that do not suffer from this limitation, and allow indexing of any string in a sub-object?
Update
Answer #1:
I found a method which gives the best of both worlds: ease of use (with a hierarchical structure), and blindingly fast native queries using full indexing on the whole tree. It involves a bit of a trick, and a method that caches the contents of parent nodes:
Answer #2:
If you use an Array instead of a List, you can descend into the child node using SODA. If you use a List, SODA doesn't support it, so you simply can't query with SODA (or anything else that depends on SODA, such as LINQ, QBE, Native queries, etc).
I'm basing this on my experience with DB40 under Scala & Java, but hopefully this is still valid: The field 'contentsNotIndexed' holds ArrayList instances, so indexing that field should only assit you in querying those ArrayList instances. If you want to query the contents of those lists efficiently, you would have to define an index on the objects you expect to find inside the lists and descend you query into the ArrayList under the 'contentsNotIndexed' field. I don't know the internals of ArrayList to suggest where that might descend though.
Depending on your needs, you can also design your class to use an array instead of an ArrayList in some cases to achieve the effect you want.