db4o reduce size of "store.db4o"?

My persistence service currently uses db4o quite successfully.

The problem is the file size. I know it was mentioned on the binding page, but my store.db4o file is around 55mb at the moment.

Storage isn’t really a problem at the moment as my Pi stores everything on an external HDD. Though I worry managing a db of that size would affect performance?

However, I can pretty much guarantee that I will never need to know the state of the upstairs hallway light from 4 months ago.

So my question is; can I clean out the database somehow?

Or is the only option to delete the file and let openHAB start a new one?

Any tips?

Thanks

55 mb is really not that big. I’ve seen db4o files in the multi-gigabytes that perform just fine. And the way that DBs work the size of the DB rarely impacts performance until they get so big they no longer fit into RAM, and even then not much.

I do not know if there is a way to clean the DB, though it seems like some sort of mechanism would be useful for the embedded databases like db4o. Because db4o is an embedded DB it does not appear to have a lot of tools you can use outside of writing your own programs.

One thing you can consider doing is for those Items you have that you don’t care about their historic data at all switch to MapDB. MapDB only saves the most recent value and is particularly useful persisting those Items you only care about for restorOnStartup. That will slow down the growth of your DB significantly.

1 Like

Cool, thanks for your answer :slight_smile:

The 55mb is multiplied by 5 plus the rsync backups I make. But it is all on an external drive so I am not too fussed on space. My concern was the knowledge of what a single text file would need to contain in order to gain a similar file size. Quite a lot.

So thanks for the reassurance :slight_smile:

I will check out MapDB. Though I am a little reluctant to change persistence again as I still don’t really understand all the different types of persistence and what they should be used for (nor am I asking you to explain it for me). Though experience thought me rrd4f only stores numerical data, and you have to take a reading once a minute in order for it work with charts. Also through experience I learned how MySQL can get in a mess if you change a value type at a later date. I seem to have the balance ok at the moment and it works (touch wood)

Out of curiosity I did try simply renaming the store.db4o to _store.db4o and restarting openHAB. This started a new db file with no obvious consequences. So I guess every few months I will just do that for a bit of a tidy up.

Keep in mind you can have more than one persistence set up at the same time and run them in parallel or pick and choose what gets saved where. I use MapDB for restoreOnStartup for all of my Items because it will hold all data types (unlike rrd4j) but only saves the most recent value so it never grows, but is useless if I actually need historical values. So I also use rrd4j for my historic values needs (charting, previousState, etc) for only those Items I need it.