Badger key-only scanning is a bit slow than expected

What version of Go are you using (go version)?

$ go version
go version go1.17 darwin/arm64

What operating system are you using?

Mac OS (M1)

What version of Badger are you using?

latest v3 release (v3.2103.1)

Does this issue reproduce with the latest master?

Not tested.

I have a reasonably big badger DB (on disk), and want to do a key-only scanning over the whole DB (to get count of certain items).

Here is the IteratorOptions (format %v): {100 false false false false false [109 105] 0}
(by the way, there are 5 bool values, while the latest documentation from badger package - github.com/dgraph-io/badger/v3 - pkg.go.dev only shows 4, why?)
I’m not requesting AllVersions, nor Prefetch any values.

Did 2 full-table scans (with different prefix), each scan takes 10-15 second to finish.
The scanned item count is 400K and 700K respectively, not a huge number if I understand correctly.
The whole DB is about 3GB DiskSizeInBytes

Does that scan fall into a reasonable range of time? I always thought badger scan (especially without requesting values) should be quite quick (say, less than 1sec).
Ideally I want to perform this kind of scan in response to web request, so the latency is important.

Thanks for any suggestions, and I’m happy to provide more details if needed.

Well, the latest result is that it takes 90 sec for 4 full-table scans: each scan covers ~20M items, no fetching (of values) and AllVersions=false.

Is that normal? still seems a bit slow to me. Anyone has suggestions?