When I was trying to change the db engine to badgerdb in some of my projects, I found the iterator Seek with prefix was pretty slow in the following situation:
- lots of keys we were seeking with prefix didn’t exist
- lots of keys have lots of versions
Then I use pprof
to found out the iterator was still running parseItem
even if the current key was not match the prefix.
So I fix this by skipping the parseItem
process when the current key is not match the prefix.
What version of Go are you using (go version
)?
go1.16.4
What operating system are you using?
ubuntu
What version of Badger are you using?
3.2103
Does this issue reproduce with the latest master?
yes
Steps to Reproduce the issue
when keys in badger has lots of versions, then iterator.Seek a prefix that didn’t exist.
It was quite slow in compare with leveldb, even in minuts total when seeking 30000 non-existent prefix
What Badger options were set?
default