zset-max-ziplist-entries 512 for example keyA, on start , keyA's value length < 512 so it's encoding is ziplist i go on call zadd, then keyA's coding convert to skiplist. Then i delete som items of until zcard keyA below 400. I find that the keyA's encoding is skiplist as before. Why? why zcard < 512 already, the encoding should convert to ziplist?

                                                                                       thank you very much!

Comment From: itamarhaber

This is by design - the conversion is one-way and Redis does not re-encode the skiplist to ziplist if the threshold is crossed on the way down.

Comment From: lygn128

ok, can you tell me the design philosophy in this? and if I add the codes as follow. Which problems will result in of this? thank you very much. if (zzlLength(zobj->ptr) <= server.zset_max_ziplist_entries) zsetConvert(zobj,OBJ_ENCODING_ZIPLIST); if (sdslen(ele->ptr) <= server.zset_max_ziplist_value) zsetConvert(zobj,OBJ_ENCODING_ZIPPLIST);

Comment From: itamarhaber

The philosophy isn't mine but trying to reverse-engineer it I'd say that scaling-in is less of a concern because: 1. Constant-sized and growing data structures represent the majority of use cases, whereas "shrinking" ones are much rarer. 2. The ability to back-and-forth between encodings may result in pathological cases where the same structures thrash while tittering on the threshold. 3. We're against complexity ;)

On Tue, Aug 2, 2016 at 6:17 AM, lygn128 notifications@github.com wrote:

ok, can you tell me the design philosophy in this? and if I add the codes as follow. Which problems will result in of this? thank you very much.

if (zzlLength(zobj->ptr) <= server.zset_max_ziplist_entries) zsetConvert(zobj,OBJ_ENCODING_ZIPLIST); if (sdslen(ele->ptr) <= server.zset_max_ziplist_value) zsetConvert(zobj,OBJ_ENCODING_ZIPPLIST);

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/antirez/redis/issues/3425#issuecomment-236783824, or mute the thread https://github.com/notifications/unsubscribe-auth/AFx1_EahJtbw59ZI3EuJgho-x7SaXUW8ks5qbrbRgaJpZM4JZbMl .

Itamar Haber | Chief Developer Advocate Redis Watch Newsletter http://redislabs.com/redis-watch-archive | &&(curat||edit||janit||) _Redis http://www.redislabs.com/_Labs http://www.redislabs.com/ ~/redis

Mobile: +972 (54) 567 9692 Email: itamar@redislabs.com Twitter: @itamarhaber https://twitter.com/itamarhaber Skype: itamar.haber

Blog http://redislabs.com/blog/ | Twitter https://twitter.com/redislabs | LinkedIn https://www.linkedin.com/company/redis-labs-inc

http://www.redislabs.com/

Comment From: itamarhaber

Closing as answered.