Why does recreating H2 database reduce the size drastically

≡放荡痞女 提交于 2019-12-10 03:36:44

问题


I have a small database (6 tables, max rows of 70,000) which was taking up 16GB of disk space. I couldn't figure out why the size was so big. I tried running compact shutdown which actually increased the size by a few megabytes instead of reducing it. I tried deleting rows, which made almost no difference.

Then I tried creating a script, dropping everything, re-creating the database from the script:

SCRIPT TO 'mydb.sql';
DROP ALL OBJECTS;
RUNSCRIPT FROM 'mydb.sql';

The size of the database went from 16GB to 6MB.

I am trying to understand what is going on in the background to cause this huge difference in size.

I am using H2 Embedded database version 1.4.192

How do I fix this issue in production? Is creating a cron job that recreates the database every month the only solution?

来源:https://stackoverflow.com/questions/41469066/why-does-recreating-h2-database-reduce-the-size-drastically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!