Does anyone know of a way to shrink/compact a db4o database?
Thanks, John
Does anyone know of a way to shrink/compact a db4o database?
Thanks, John
What do you mean by compact/shrink? Make an existing database smaller? Or do you want to compress the database?
One of roles for this is defragmentation. This frees up unused space in the database. When you delete objects, the database doesn't shrink. Instead the space is marked as free for new objects. However overtime with a the manipulation of the database the file get fragmented. So defragmentation brings back unused space in the database.
When you store a lot of strings, you should consider using UTF8 encoding instead of default full unicode. This saves a lot of space, because a now a character uses only one byte.
EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();
config.common().stringEncoding(StringEncodings.utf8());
ObjectContainer database = Db4oEmbedded.openFile(config,"database.db4o");
Note that you cannot change this setting for existing databases! You need to defragment the database in order to change the string encoding.
To compress the database you could use a compressing storage-implementation. However I don't know any available implementation which does this.