Hi guys.
Here is how the things work.
The DB size is the total size of all files stored into the db/baasbox folder.
These files ARE the database, and in this location there are not only data files, but also index files and other files used by the db system.
BaasBox uses OrientDB as persistence engine, so the first thing to have in mind is how this database works.
OrientDB creates WAL (Write Ahead Logging) files to manage durability of the database.
These files, by default, can growth up to 4GB and they are used in case of crashes to try to fix the database inconsistencies.
BaasBox, since version 0.9.2, set this limit to 300MB, and it can be overridden via command line (-Dstorage.wal.maxSize parameter).
This simply means that the total DB size is affected by these files that are, as you noted, flushed and deleted if the server is stopped.
Furthermore BaasBox defines indexes on some fields, and these indexes are stored in several files into this same folder.
The size of these indexes is not shown into the collection size section of the console.
In addition to this BaasBox adds its own data to each inserted document.
For every document, BaasBox creates another private data structure that is used to manage links among documents and files.
These private data are not shown into the collection section too.
For those who were curious and know OrientDB, these data are stored into a class called _BB_NodeVertex that extends V, meanwhile the links are stored directly into the E class.
As far as the single document size is concerned, you maybe noted that usually they are bigger than you expected. This happens because, in each document, BaasBox stores:
- the ID of the document
- the username that actually created the record
- the creation date
- data related to the permissions on that record (each BaasBox collection is an OrientDB class that extends the ORestricted class)
- an embedded document used to store audit information: who and when the latest update happened
For each Link, BaasBox stores:
- the ID of the Link
- the username that created the link
- the creation date