I have an already sorted set in memory of size (N) and want to dump it into redis, can it be done in O(N) if inserted head or tail first? or it doesn't matter, and the insertion will be O(log(N!)) ~ O(N log(N))
For further details, redis sorted sets are implemented using a hashmap and a skiplist (for the ordering).
EDIT: this question remains unanswered since quite a bit, or at least the answer is a bit ambiguous for me: Redis: Is ZADD better than O(logN) when the inserted element is at the beginning or end?
Here are the results from my "empirical" approach which suggest there may be a slight benefit to having order :)
(.venv)foo@bar:~/so_bounty$ python main.py
ascending order
5.57414388657
descending order
5.72963309288
random order
6.75937390327
0 score
5.79048109055
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With