HSQLDB and .lobs file size

不问归期 提交于 2019-12-22 07:04:42

问题


I'm using a HSQLDB database in Java which stores files in a column defined as a BLOB.

When I add a table row with a file/BLOB to my table the .lobs file increases in size of the file/BLOB. When I add another file to my table it increases in size again (2 x BLOB size).

So, I implemented a test method which iterates 10 times and writes the same file to my table and deletes it right after the insert.

Now, my .lobs file is 10 x file size... even though I've deleted all the table rows which contained the file.

I've tried to execute CHECKPOINT DEFRAG but nothing happens. The .lobs file stay the same file size.

This worries me since my webapp I'm creating is going to write lots of files to my database and even if the table rows with the file (BLOB) will after a while get deleted the .lobs file will always increase or stay in the same size and eventually eat all my disk space.

Am I missing some setting or is this the expected behavior of HSQLDB and BLOBs?

Thanks a lot!

Kind regards, Andreas


回答1:


This is normal.

All the deleted lob spaces are recorded. After a CHECKPOINT, the spaces are reused if you insert new lobs.

In a production database there are recurring cycles of insert and delete. In the log run, the .lobs file size will not exceed the actual size of the lobs in the database by a very large amount.

Update:

The reason for .lobs file to grow until a checkpoint is to allow data recovery in case there is a system crash.

HSQLDB version 2.3.0 and later versions truncate the .lobs file at CHECKPOINT if there is empty space at the end of the file after deleting the lobs.



来源:https://stackoverflow.com/questions/13921277/hsqldb-and-lobs-file-size

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