iterator.seek() so slow
I use rocksdb to store cdp(Continuous Data Protection) data. key is 'p'+nanosecond timestamp(uint64), value is sector + bio data.
my env:

my code:

Expected behavior
iterator.seek() returns soon.
Actual behavior


seek() need 1~2h or more on my other db(206g).
I found SeekToFirst() is slow too.
Do you have a lot of Deletes in your app? From the perf_context, it seems that a lot of data block (block_read_bytes) is read due to skipping deleted entries (internal_delete_skipped_count). Doing a full manual compaction might help remove all the tombstones. A similar issue before: #10300
@cbi42, thank your answer. I tried db.CompactRange(Range{nil, nil}), and iterator.seek() returns soon. But CompactRange(42g) need 11 minutes, it's too long.
There is a lot of writing rocksdb in my application. Do you have any optimization suggestions?
Hi @meilihao, I'm not an expert on compaction, so my suggestion on that is limited and others are welcomed to add more. I think tuning options that allow more compactions in the background should be helpful. You can checkout some wikis here: https://github.com/facebook/rocksdb/wiki/Compaction, https://github.com/facebook/rocksdb/wiki/Setup-Options-and-Basic-Tuning, https://github.com/facebook/rocksdb/wiki/Prefix-Seek.