HSQLDB和.lobs文件大小 [英] HSQLDB and .lobs file size

查看:114
本文介绍了HSQLDB和.lobs文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java中的HSQLDB数据库,该数据库将文件存储在定义为BLOB的列中.

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

当我向表中添加包含文件/BLOB的表行时,.lobs文件的大小会增加.当我将另一个文件添加到表中时,它的大小再次增加(2 x 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).

因此,我实现了一种测试方法,该方法可以迭代10次并将相同的文件写入到我的表中,并在插入后立即将其删除.

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.

现在,即使删除了包含该文件的所有表行,我的.lobs文件也只有10倍文件大小.

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

我尝试执行CHECKPOINT DEFRAG,但是什么也没有发生. .lobs文件保持相同的文件大小.

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

这让我很担心,因为我正在创建的Web应用程序将向数据库中写入大量文件,即使带有文件(BLOB)的表行将在一段时间后被删除,.lobs文件也将始终增加或保持不变大小相同,并最终吞噬了我所有的磁盘空间.

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.

我是否缺少某些设置,或者这是HSQLDB和BLOB的预期行为吗?

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

非常感谢!

亲切的问候, 安德烈亚斯(Andreas)

Kind regards, Andreas

推荐答案

这很正常.

记录所有已删除的lob空间. CHECKPOINT之后,如果您插入新的lob,则会重新使用空格.

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

在生产数据库中,存在重复的插入和删除循环.在日志运行中,.lobs文件的大小不会大大超出数据库中lob的实际大小.

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.

更新:

.lobs文件增长到检查点的原因是为了在系统崩溃时允许恢复数据.

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

如果删除了lob,则文件末尾的空白处,HSQLDB 2.3.0版和更高版本会在CHECKPOINT处截断.lobs文件.

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.

这篇关于HSQLDB和.lobs文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆