Why is my H2 database 7x larger on disk than it should be?

梦想与她 提交于 2019-12-04 07:01:00

问题


I have an H2 database that has ballooned to several Gigabytes in size, causing all sorts of operational problems. The database size didn't seem right. So I took one little slice of it, just one table, to try to figure out what's going on.

I brought this table into a test environment:

The columns add up to 80 bytes per row, per my calculations.

The table has 280,000 rows.

For this test, all indexes were removed.

The table should occupy approximately

80 bytes per row * 280,000 rows = 22.4 MB on disk.

However, it is physically taking up 157 MB.

I would expect to see some overhead here and there, but why is this database a full 7x larger than can be reasonably estimated?

UPDATE

Output from CALL DISK_SPACE_USED


回答1:


There's always indices, etc. to be taken into account.

Can you try:

CALL DISK_SPACE_USED('my_table');

Also, I would also recommend running SHUTDOWN DEFRAG and calculating the size again.




回答2:


Setting MV_STORE=FALSE on database creation solves the problem. Whole database (not the test slice from the example) is now approximately 10x smaller.

Update

I had to revisit this topic recently and had to run a comparison to MySQL. On my test dataset, when MV_STORE=FALSE, the H2 database takes up 360MB of disk space, while the same data on MySQL 5.7 InnoDB with default-ish configurations takes up 432MB. YMMV.



来源:https://stackoverflow.com/questions/49929860/why-is-my-h2-database-7x-larger-on-disk-than-it-should-be

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