在使用文件哈希数据库的京都内阁数据库中,如何避免文件大小增加?

发布于 2024-10-05 12:13:00 字数 361 浏览 0 评论 0原文

我使用以下命令打开:

db.open("db.kch#tune_defrag=10000", DB.OWRITER | DB.OCREATE)

我正在放置和删除元素。执行结束时,数据库为“空”,count()函数返回0,因为我删除了所有元素。为什么重复测试时文件大小总是增大?是否可以运行“垃圾收集器”之类的东西来清理已删除的寄存器?如果我执行相同的测试 100 次,我就有一个 500 MB 大小的数据库,即使我只有 2 条记录。

我尝试添加“tune_defrag=10000”,但我认为它效果不佳。

Obs.:一个寄存器小于1K,我不明白为什么寄存器占用这么多磁盘空间。

感谢您的帮助

I am using the follow to open:

db.open("db.kch#tune_defrag=10000", DB.OWRITER | DB.OCREATE)

I am putting and removing elements. At the end of execution, the database is "empty", the count() function returns 0, because I remove all elements. Why the file size always increase when I repeat the test? Is it possible to run something like "garbage collector" to clean the removed registers? If I execute the same test 100 times, I have a 500 MB size database, even I have only 2 records.

I tried to put the "tune_defrag=10000" but I think it didn't work fine.

Obs.: a only register is less than 1K, I don't understand why the registers take so much space in disk.

Thanks for any help

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

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

发布评论

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

评论(4

北渚 2024-10-12 12:13:00

试试这个:

db.kch#dfunit=8

这意味着 KC 每检测到 8 个碎片就会运行碎片整理,而 Mikio 实际上建议使用 8 个碎片。

此处列出了可用选项,但它还需要一些改进。

http://fallabs.com/kyotocabinet/command.html

Try this:

db.kch#dfunit=8

That means the KC runs defrag for every 8 fragmentation detected, and 8 is actually recommended by Mikio.

Available options are listed here, however it could use some polish.

http://fallabs.com/kyotocabinet/command.html

娇俏 2024-10-12 12:13:00

运行:

kchashmgr defrag path_to_kcabinet_file

是我为获取数据库文件“调整大小”所做的操作。我没有找到对此的 api 访问,这就是为什么我使用 kchashmgr 实用程序通过 shell 命令来执行此操作(显然这可以从程序内部调用)。

running:

kchashmgr defrag path_to_kcabinet_file

is what i do to get the db file 'resized'. I didn't find the api access to this, that's why i do it with a shell command using kchashmgr utility (obviosuly this can be called from inside a program).

那伤。 2024-10-12 12:13:00

我没有使用过这个特定的数据库,但在其他一些数据库中,解决此问题的方法是将数据库复制到新数据库中,然后删除旧数据库。确保复制良好后:)。

我已经将这个过程实现到生产系统中,只要它编码得非常好,它就应该可以工作。

I haven't used this particular db but in some other ones a hack to resolve this issue is to copy the db into a new one, and then delete the old one. After making sure it copied well :).

I've implemented this process into production systems, as long as it is coded really really well it should work.

只等公子 2024-10-12 12:13:00

粗略地浏览一下京都文档,似乎没有任何方法可以调整大小或以其他方式清理已删除记录的数据库......或者真正以任何方式管理它。

该项目看起来距离“生产就绪”还有很长的路要走。如果你真的想实现它,我建议联系项目所有者(http://fallabs.com/),看看他们是否有一些急需的实用功能的计划。

否则,我建议转向另一个更成熟的 nosql 风格数据库。

From a cursory look through the kyoto documentation it doesn't appear that you have any way to resize or otherwise clean the database of deleted records... or really to manage it in any way shape or form.

That project looks like it is a long way off from being "production ready". If you really want to implement it, I'd suggest contacting the project owners (http://fallabs.com/) and seeing if they have any plans for some much needed utility functions.

Otherwise, I'd suggest moving to a different nosql style database that is a bit more mature.

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