ZREVRANGEBYSCORE Optimization for out of range offset#5773
ZREVRANGEBYSCORE Optimization for out of range offset#5773oranagra merged 5 commits intoredis:unstablefrom
Conversation
|
this is a meaningful optimization, i think. @antirez |
|
Hi @omigafu, this sounds good, I guess that every time there is a loop in which we scan with LIMIT for pagination or alike, at least the final query that would just skip all the elements will return ASAP. I wonder however if you had a real world experience about that. Btw note that the PR is wrong because it inherits a bug that was already here, so I'll merge it in a few days, after fixing the bug I introduced when migrating to RESP3. Basically it should not reply with a NULL reply when the index is out of range, but with an empty array. |
|
Hi @antirez , sorry to see your reply so late. |
|
@oranagra do you have any time to review it? |
|
@omigafu thank you. |
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 it is easy to determine whether the offset is greater than the length of zset at first, and If it exceed the length of zset, then return directly. Co-authored-by: Oran Agra <[email protected]>
Hi @antirez , there is a place optimized.
The edge case, where the offset exceeds the length of the zset. This is an invalid offset. It should be better to return directly. see issue #5767