15. Indexesdb4o 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 before you open an IObjectContainer/IObjectServer:
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 IObjectContainer/IObjectServer and you use the Foo class the first time in your application. 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 IObjectContainer/IObjectServer. To drop an index you would also issue a configuration call in your db4o configuration method:
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:
For creating and dropping indexes on large amounts of objects there are two possible strategies: (1) Import all objects with indexing off, configure the index and reopen the ObjectContainer/ObjectServer. (2) Import all objects with indexing turned on and commit regularly for a fixed amount of objects (~10,000). (1) will be faster. (2) will keep memory consumption lower. |