cberner / redb

An embedded key-value database in pure Rust
https://www.redb.org
Apache License 2.0
3.07k stars 137 forks source link

Inserting data with `Durability::None` makes database file grow rapidly #810

Closed tqwewe closed 1 week ago

tqwewe commented 2 months ago

When inserting data with the Durability::None in a commit, the database file grows extremely large compared to using something like Immediate.

Ideally, I'd like to flush the database every 10 seconds or so, as the data being stored can be recomputed and isn't super important.

Inserting a (&str, Vec<u64>) with 100,000 u64's (being inserted one at a time) results in the file growing to dozens of GB before I need to forcefully stop my app. However doing so with the Durability set to Immediate is just a few MB.

adamreichold commented 1 month ago

Ideally, I'd like to flush the database every 10 seconds or so, as the data being stored can be recomputed and isn't super important.

Note that you can implement this using the public API: Have a thread/task run something like db.begin_write()?.commit()?; every 10 seconds or so to flush the non-durable transactions using a single durable transaction.

cberner commented 1 week ago

Yes, this is one of the limitations of redb. Performing a large number of Durability::None commits, sequentially, is not recommended