apache / kvrocks

Apache Kvrocks is a distributed key value NoSQL database that uses RocksDB as storage engine and is compatible with Redis protocol.
https://kvrocks.apache.org/
Apache License 2.0
3.51k stars 461 forks source link

Optimize the implementation of command RANDOMKEY #1658

Open PragmaTwice opened 1 year ago

PragmaTwice commented 1 year ago

Search before asking

Motivation

Currently the result key of command RANDOMKEY is not randomized enough, so we'd better do some research and optimize it.

Solution

No response

Are you willing to submit a PR?

Yangsx-1 commented 1 year ago

I'll try this.

torwig commented 1 year ago

@Yangsx-1 Assigned.

Yangsx-1 commented 1 year ago

Can we add a random_scan function? This function will select the key at random intervals during the scan, after scan we can randomly select keys from the scan result. This may be more random. @PragmaTwice @git-hulk @torwig

PragmaTwice commented 1 year ago

Could you give more detailed design of it? I cannot get your point well.

Besides, I think one possible way is to add more random cursors, and select one of them each time.

Yangsx-1 commented 1 year ago

Could you give more detailed design of it? I cannot get your point well.

Besides, I think one possible way is to add more random cursors, and select one of them each time.

Oh, i mean, we can add a random interval in the iteration of scaning.

For example, the scan result may be 1 2 3 4 5 6 now, after add a random interval, the result may be 1 3 6 9 10 12 rather than pure sequential scanning. And we can select a key from the result of random scan.