ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count] When the offset is too large, the query is very slow. Especially when the offset is greater than the length of zset. For this invalid query, I think it should determine whether the offset is greater than the length of zset at first, and If it exceed the length of zset, then return directly.

Comment From: itamarhaber

Hello @fuxiaotong

This is the expected behavior, see the docs for ZRANGEBYSCORE:

Keep in mind that if offset is large, the sorted set needs to be traversed for offset elements before getting to the elements to return, which can add up to O(N) time complexity.

The edge case, where the offset exceeds the length of the zset, could perhaps be optimized to break early, although it will have little impact overall.

Comment From: omigafu

thanks for your reply @itamarhaber