cubdb
cubdb copied to clipboard
Feature Request: `CubDB.number_of_writes/1`
I would like to propose, on the same vein as CubDB.dirt_factor/1, I think it will be useful to have a public API with CubDB.number_of_writes/1, so we could manually trigger CubDB.compact/1 based these two factors.
Thank you.
Hi @eksperimental , Would that return the number of writes since the last compaction?
The dirt factor is calculated on the basis of the number of writes since the last compaction, and the number of entries in the database. It basically estimates how much data stored in the file is unreachable “garbage” relative to the size of the database. Automatic compaction is triggered when the dirt factor is over a given threshold, AND the number of writes since the last compaction is at least a given number.
If I understand, you would like to have a function that tells you the number of writes since the last compaction. That’s possible, but can I ask what’s the use case, and in particular why auto compaction won’t work in that case?
I have a cron job and I want to manually compact only when the cron job is executed, so I would be checking the number of writes since the last compaction AND the dirt factor, but based on what you say the dirt factor is already calculated, but the docs mentions both value as a requirement to trigger the autocompact.
I can add such feature in the next release, possibly under a slightly different name (maybe CubDB.writes_since_compaction).
Sounds great. Looking forward to it. Thank you @lucaong