Updating indexed fields always takes longer as the index should be updated as well. This is shown in the following test:
UpdatePerformanceBenchmark.cs: RunIndexTest private void RunIndexTest() { System.Console.WriteLine( "Update test for objects with and without indexed fields"); int objectsToUpdate = 100; Init(); System.Console.WriteLine("Updating " + objectsToUpdate + " of " + _count + " objects"); Clean(); Open(Configure()); Store(); UpdateItems(objectsToUpdate); Close(); Clean(); Init(); System.Console.WriteLine("Updating " + objectsToUpdate + " of " + _count + " objects with indexed field"); Open(ConfigureIndexTest()); Store(); UpdateItems(objectsToUpdate); Close(); }
UpdatePerformanceBenchmark.cs: Init private void Init() { _count = 1000; _depth = 90; _isClientServer = false; }
UpdatePerformanceBenchmark.cs: ConfigureIndexTest private IConfiguration ConfigureIndexTest() { IConfiguration config = Db4oFactory.NewConfiguration(); config.Io(new MemoryIoAdapter()); config.ObjectClass(typeof(Item)). ObjectField("_name").Indexed(true); return config; }
The results:
Update test for objects with and without indexed fields
Updating 100 of 1000 objects
Store 90000 objects: 7466ms
Updated 100 items: 295ms
Updating 100 of 1000 objects with indexed field
Store 90000 objects: 6839ms
Updated 100 items: 441ms
Download example code: