Badger Documentation limited or Feature removed?

Sorry for the lack of clarity.

Badger, a key-value database is inspired from RocksDB and uses LSM tree as the underlying data structure. LSM tree is optimized for heavy-write workloads which is performed by performing sequential writes. This means that a new entry(key-value) would be inserted into the Tree even if the key for it already exists.
For cleaning up of tree (removing old/stale data), it has to rely upon Compaction. This compaction process runs periodically, identifies the stale data and cleans up the tree.

Badger also provides a mechanism to keep multiple versions of same key (by setting NumVersionsToKeep). This is useful for various purposes. Dgraph uses this property of Badger.

For simplicity let’s assume you want to keep a single version of a Key, i.e., if you update a key with a new value, you don’t care about the older value. You want that older value to be cleaned up.

Each time you set a key-value pair (say key1: value2), a new entry(key-value pair) is inserted into the DB. As you have set NumVersionsToKeep=1 (its the default in badger), the older entry(key1: value1) for the same key is marked as stale. This value is no longer visible to you and would eventually be cleaned up by the compaction process. Now if you do txn.Get(key1) you would get value2.

The performance difference is only equivalent to inserting a new Key Value. While the memory would eventually be cleaned. But if your values are very large (>1KB) and you are frequently updating that, then garbage collection would take some time.

No time constraint as such. But it would eventually be cleaned up maintaining your DB in a healthy state.

Automatic garbage collector (compaction + value log GC) will clean that up for you. You don’t need to run it yourself.

Please feel free to ask further clarifications.