问题
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