You are here: Configuration > Id System

Id System

The id-system configuration applies to the embedded- and the server-mode of db4o. There are tree different id-systems-available. All the id system configuration is accessible via the id-system-property on the configuration-object.

Note that you cannot change the id-system for an existing database. You need to defragment the database in order to change the id-system.

The id-system is responsible to mapping a object id to the physical location of an object. This mapping can have significant impact on the performance.

Stacked BTree Id-System

This setting uses a stack of two BTree's on top of an InMemoryIdSystem. This system is scalable for a large number of ids.

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.IdSystem.UseStackedBTreeSystem();
IdSystemConfigurationExamples.cs: Use stacked B-trees for storing the ids
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.IdSystem.UseStackedBTreeSystem()
IdSystemConfigurationExamples.vb: Use stacked B-trees for storing the ids

Single BTree Id-System

This setting uses a single BTree on top of a in memory id system. This system works great for small databases. However it cannot scale for a large number of ids.

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.IdSystem.UseSingleBTreeSystem();
IdSystemConfigurationExamples.cs: Use a single B-tree for storing the ids.
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.IdSystem.UseSingleBTreeSystem()
IdSystemConfigurationExamples.vb: Use a single B-tree for storing the ids.

In Memory Id-System

This id-system keeps all ids in memory. While accessing the ids if fast, all ids have to be written to disk on every commit. Therefore it can be used only for tiny databases.

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.IdSystem.UseInMemorySystem();
IdSystemConfigurationExamples.cs: Use a in-memory id system
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.IdSystem.UseInMemorySystem()
IdSystemConfigurationExamples.vb: Use a in-memory id system

Pointer Based Id-System

This id system uses pointers to handle ids. Each id represents a pointer into the database-file. This makes the id-mapping simple. However since it's a pointer, you cannot change the location. Therefore this system leads to more fragmentation and performance degradation as the database grows.

This id system is here to ensure backward-compatibility. It's not recommended to use for new databases.

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.IdSystem.UseInMemorySystem();
IdSystemConfigurationExamples.cs: Use a in-memory id system
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.IdSystem.UseInMemorySystem()
IdSystemConfigurationExamples.vb: Use a in-memory id system

Custom Id-System

It's possible to implement your own id system. You can pass an factory which creates your id-system implementation.

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.IdSystem.UseCustomSystem(new CustomIdSystemFactory());
IdSystemConfigurationExamples.cs: use a custom id system
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.IdSystem.UseCustomSystem(New CustomIdSystemFactory())
IdSystemConfigurationExamples.vb: use a custom id system