You are here: Tuning > Performance Hints > Database Size

Database Size

If you are concerned about the size of your database file, it is importnant to understand what contributes to it and what are the strategies to keep it down.

Object Overhead

When you create a new db4o fatabase file - it contains only the header and has a fixed size. As soon as you start storing the information the file will grow. The size overhead per object depends on the typehandler implementation.

In general the object consists of internal ID and value types, i.e. integers, arrays, enums etc. Overhead per object type is ID, which is integer. The overhead for value type is an integer value showing which value type is it, i.e. int or string etc.For variable length value types, there is a long value to store the length. If object contains another complex object - the id of another object is referenced in the top-level object. If you decide to use UUIDs and version number for your objects, you will get an additional overhead:

UUID = 35 bytes (signature part) + 8 bytes (long part) version number = 8 bytes.

Additional overhead per object will appear from using indexes and will depend on the amount of indexes fields and indexes value types.

Block Size

Block Size is a configurable value, which defines the way information is stored in db4o database. Using bigger block sizes can result in unnecessary growth of the database. For motr information see Increasing The Maximum Database File Size

Freespace

Freespace appears in db4o database after unneeded objects were deleted. The amount of the freespace can be controlled from the configuration. Another option to get rid of the freespace is Defragment. It is a good practice to run Defragment regularly to maintain the minimum database file size.