为什么H2数据库文件大小的生长大于数据大小

发布于 2025-01-18 11:41:48 字数 621 浏览 4 评论 0原文

我有一个H2数据库文件,文件大小已增长到5GB。我删除了一些数据以减少文件的大小。但是,即使从数据库中删除了一半的记录后,文件大小仍然保持不变。

我尝试了以下所有选项来减少数据库大小,但它们都不适合我。

1. Executed shutdown compact (after closing all the connection).
2. Executed shutdown defrag.
3. Executed checkpoint.
4. Used the property MV_STORE=FALSE along with the database url.
5. Used the property RETENTION_TIME=30000 along with the database url.

我的连接字符串看起来如下:

"jdbc:h2:" + <db file path>;MVCC=TRUE;DEFAULT_LOCK_TIMEOUT=10000;COMPRESS=TRUE;

注意:

  1. 我们正在关闭打开的交易。
  2. 文件中没有5GB数据。

谁能建议我进行一些工作或修复以减少数据库大小

I have a h2 database file and the file size has grown to 5GB. I have deleted some of data to reduced the size of the file. But the file size still remains the same even after deleting the half of the records from the database.

I have tried all the below options to reduce the database size but none of them have worked for me.

1. Executed shutdown compact (after closing all the connection).
2. Executed shutdown defrag.
3. Executed checkpoint.
4. Used the property MV_STORE=FALSE along with the database url.
5. Used the property RETENTION_TIME=30000 along with the database url.

MY connection String looks like below :

"jdbc:h2:" + <db file path>;MVCC=TRUE;DEFAULT_LOCK_TIMEOUT=10000;COMPRESS=TRUE;

NOTE :

  1. We are closing the transaction which we are opened.
  2. We don't have 5GB of data in the file.

Can anyone suggest me some work around or fix to reduce my database size

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

愿与i 2025-01-25 11:41:48

因为当您从数据库中删除某些记录时,数据文件不会减少。这是由于性能原因。因此 h2 将替换文件中的字节块或追加新的字节块,但不会删除任何内容,因为它需要重写整个文件。

要么您没有像您想象的那样进行压缩,要么您没有删除有意义的(数量)数据。

Because data file is not reduced when you eg delete some records from the database. This is due to performance reasons. So h2 will either replace byte block in a file or append new one, but will not remove anything as it would require rewriting whole file.

Either you didn't compact as you think you did, or you did not delete meaningful (amount) data.

独守阴晴ぅ圆缺 2025-01-25 11:41:48

通常文件大小比数据大小大得多,因为其中保存了多个版本的数据以适应并发事务处理。

要减小文件大小,请使用“shutdown defrag”或“shutdown compact”(它们现在是相同的),
假设您使用的是最新版本。

这是将文件大小降低到数据大小(大致)的唯一方法。
如果是 1.4.197 或更早版本,请升级。

你的行为 3)、4)、5) 对我来说没有任何意义。如果有的话,我会保留 RETENTION_TIME=0 。

Normally file size is much bigger than data size, because multiple versions of data are kept in it to accommodate concurrent transactions processing.

To reduce file size use "shutdown defrag" or "shutdown compact" (they are the same now),
assuming you are using recent version.

This is the only way to bring file size down to data size (roughly).
Upgrade, if it's 1.4.197 or older.

Your actions 3), 4), 5) do not make any sense to me. I would have RETENTION_TIME=0, if anything.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文