You are here: Troubleshooting > Speed and Scalability Issues > Increasing The Maximum Database File Size > What Contributes to the Database Size

What Contributes to the Database Size

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

Object Overhead

When you create a new db4o database file it contains only the header. As soon as you start storing information the file will grow. The size overhead per object depends on the object type.

In general an object consists of value types, i.e. integers, arrays and references to other objects. If you decide to use UUIDs and version number for your objects, you will get an additional overhead.

Your Objects Data

Of course your objects consume the space which is needed to store the data. For strings this space heavily depends on the encoding. If you want to keep the database size down consider using the UTF8 encoding.

Indexes

Indexes consume additional space. Therefore you should only index fields which you actually use in queries. Furthermore you might want to remove a class-index when you never query for that type.

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 more information see Increasing The Maximum Database File Size

Freespace

Freespace appears in db4o database after unneeded objects have been 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.

Lost Space on Crash / Process Killed

When you are using the default freespace manager the free space is lost when the database crashes or the process is killed. This is especially true when you kill your process with the debugger while developing. In regular operations you should always try to close the database regularly. When you defragment the database the lost freespace is reclaimed.