How to decrease database size?

53 views
Skip to first unread message

Jack Green

unread,
Jul 30, 2020, 8:38:02 AM7/30/20
to H2 Database
I've noticed that my H2 database seems to grow and grow.

I've got a database, which includes a table with 1.5 million rows.
This database is currently 6GB.

If I run a query to add a new column to the table, and modify an existing column, and then disconnect - it grows to 22GB.

If I then reconnect and run a SHUTDOWN COMPACT, the shrinks to 0.7GB.

Clearly theres gigabytes of redundant data being stored, so my question is how can I reduce the peak size of the database?

I've assumed it's transaction logs / checkpoints thats causing this, but I don't know for sure.

Are there any parameters I can tweak (e.g. the RETENTION_TIME) to improve this?

Andrei Tokar

unread,
Jul 30, 2020, 8:08:12 PM7/30/20
to H2 Database
Setting RETENTION_TIME to a smaller value, or even zero, will help. Also keeping database up and let it do background housekeeping after massive changes (or do changes at slower pace) will help too, but most effective way to reduce file size to a bare minimum, as you already know is SHUTDOWN COMPACT command.
Reply all
Reply to author
Forward
0 new messages