New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
why "ZSCAN" 's "COUNT" didn't work? [Redis version 2.8.7] #1723
Comments
Hello. It is clearly stated in the documentation, please read it, it's a good read :-) |
Sorry. I still don't know it can or not use the "COUNT count" in the documentation --> http://redis.io/commands/zscan
If it havd been can used. which version can use it? |
What you're looking for is:
|
Got it, Thank you. apologize for my mistake. |
Thanks for pointing this out as I had the same question, so it is not so obvious and I do RTFM. Why is it the case the "usuall all the elements are returned"? |
Check out the comment at https://github.com/antirez/redis/blob/95b1979c321eb6353f75df892ab8be68cf8f9a77/src/db.c#L473-L479 Short version: for Redis containers using efficient immediate values (ziplist/skiplist), the entire container is returned because it's all one sequential blob in memory. Also, the efficient immediate value containers are optimized for storing small numbers of things, so returning the entire container is assumed to be okay because they should only ever have a small number of things in them. Though, if you manually change the maximum ziplist entry count from 64 to 64,000, you may get a surprise when using SCAN because your COUNT will always return chunks of 64,000 elements. |
I store 20,000,000 items in an IntSet and SSCAN with COUNT 5000 still return all items. Could we consider this as a bug, mean SSCAN should respect the COUNT parameter? |
@vvhungy you can't store 20M items an in intSet, since after a small amount the intSet is converted into an hash table. |
@antirez: I did it with Redis 3.0.2 using config setting: set-max-intset-entries 20000000. So I propose a config, let say: "scan-max-elements-returned" to prevent redis returning too many data that may slow down server performance, and *SCAN must always respect the COUNT parameter as long as COUNT <= scan-max-elements-returned . |
As was mentioned earlier in this thread the It's been a while since I looked at the scan code, but I don't think it is trivial to maintain a cursor for blob structures like intset and ziplist. Also, IMHO unless you know for a fact that you're only inserting to the tail of this list, setting |
@michael-grunder: agree with you in the second point, sure I should be aware when doing this. Also with "scan-max-elements-returned" config, we can actively prevent the *SCAN command to ruin server performance. |
ZSCAN "feed_uid_32" 0 COUNT 1
didn't work? in [Redis version 2.8.7]. it return me all the "SortedSet" items:
The text was updated successfully, but these errors were encountered: