Decrease database size - scheduled maintenance task?

42 views
Skip to first unread message

Jack Green

unread,
May 18, 2020, 5:17:15 AM5/18/20
to H2 Database
I have an H2 database where, after loading the data, the database grows to 24GB.

If I dump & recreate the database, this shrinks to 1.5GB - but obviously this takes time to do.

I'd like to try to reduce the size of the database a little - I'm not necessarily looking at compression or anything, but I'm assuming some of this 20x overhead is checkpoints etc.

I also know that by default H2 spends ~500ms compacting the database, but I'd rather not leave this work until the end.

Is it possible to run this compaction task in the background on an ongoing basis, like other databases do?

Thanks in advance.

Jack Green

unread,
May 18, 2020, 9:04:49 AM5/18/20
to H2 Database

Having read over the documentation again, I've tried SHUTDOWN COMPACT which has dropped the size considerably - 589MB.

However, SHUTDOWN COMPACT shuts down the database (obviously) - which I don't want to do. Is there a way to just COMPACT while running (ideally in the background).
Reply all
Reply to author
Forward
0 new messages