Dmitry
Dmitry

Reputation: 136

redis zrange vs zrangebyscore(-inf +inf)

Which method is better in next case:

I need to get a few elements which are ordered by score, I can use both methods:

 1. zrange myZset 1 5 WITHSCORES
 2. zrangebyscore myZset -inf +inf WITHSCORES 4 1

In redis documentation both methods has Time complexity: O(log(N)+M)

So, is there any diference in time execution within my case

Upvotes: 0

Views: 1159

Answers (1)

Dmitry
Dmitry

Reputation: 136

Time with 10k itterations on 60k elements in zset:

zrange myZset 1 5 WITHSCORES: 0.70670008659363

zrangebyscore myZset -inf +inf WITHSCORES 4 1: 1.0469110012054

Upvotes: 3

Related Questions