When you need to store large sets, you can use db4o's big set. This big-set operates directly on top of B-trees, which are also used for indexes. The big-set doesn't need to activate all items to perform its operations. For example when you check if the set already contains a member, the big-set can do that without activating all its items. Especially lookup-operation like contains perform much faster with a big set.
Not that currently the big set implementation only works in embedded-mode, but not in client-server mode.
You can create a new big-set with the CollectionFactory:
ICollection<Person> citizen = CollectionFactory.ForObjectContainer(container).NewBigSet<Person>(); // now you can use the big-set like a normal set: citizen.Add(new Person("Citizen Kane"));
Dim citizen As ICollection(Of Person) = _ CollectionFactory.ForObjectContainer(container).NewBigSet(Of Person)() ' now you can use the big-set like a normal set: citizen.Add(New Person("Citizen Kane"))
After that, the big-set behaves just like an ordinary set. Except that the big-set used the object-identity instead of the object-equality to compare the items. So when you add a equal object with a different identity, it will be added to the set. You can add, remove and iterate over the items or check if an item is already in the set. The items will be loaded and activated on demand, for example when you iterate over the set.
Person aCitizen; using (IEnumerator<Person> aCitizenEnumerator = city.Citizen.GetEnumerator()) { aCitizenEnumerator.MoveNext(); aCitizen = aCitizenEnumerator.Current; } Console.WriteLine("The big-set uses the identity, not equality of an object"); Console.WriteLine("Therefore it .contains() on the same person-object is " + city.Citizen.Contains(aCitizen)); Person equalPerson = new Person(aCitizen.Name); Console.WriteLine("Therefore it .contains() on a equal person-object is " + city.Citizen.Contains(equalPerson));
Dim aCitizen As Person Using aCitizenEnumerator As IEnumerator(Of Person) = city.Citizen.GetEnumerator() aCitizenEnumerator.MoveNext() aCitizen = aCitizenEnumerator.Current End Using Console.WriteLine("The big-set uses the identity, not equality of an object") Console.WriteLine("Therefore it .contains() on the same person-object is " & city.Citizen.Contains(aCitizen)) Dim equalPerson As New Person(aCitizen.Name)