Hey, Badger team:
I have a use case where I need to scan the whole badger database, stop at ~10K guessed locations. If the guessed location actually exists, stop there and read some stuff.
I can have 2 possible solutions:
- txn.NewIterator, and Seek to any of the guess locations, verify it’s really the key I want.
- txn.NewKeyIterator, and supply the guessed location.
Solution 2 seems better as (according to documentation), badger can take advantage of internal bloom filter and make quick decisions. However, there is currently no way to reuse an iterator (created by NewKeyIterator), as it’s not possible to change the Prefix and the opt.prefixIsKey on-the-fly.
So my question:
- how much performance difference is solution 1 and 2?
- can a regular iterator (created by txn.NewIterator) take advantage of bloom filter somehow? I know internally the prefix cannot include the timestamp (for bloom filter to work), and there is no good way to enforce that.
- is there a way to re-use an iterator (created by txn.NewKeyIterator), with different KeyPrefix? that would be ideal.