I want to get random key from my rocksdb. Is there a way to do it efficiently?
My inefficiency way is - I have A Person object in my DB and it has a unique key for id and I want to get a random Id.
I can get a list with all the ids that store in the DB then chose a random index between 0 to the size of the list and than get the randomId from that list.
but if I have a lot of Objects in the DB the run time for get all the ids take a lot of time. is there a better way?
Aucun commentaire:
Enregistrer un commentaire