REDIS: Numeric keys (1,2,3..) vs compressed keys (A9z3,A9z4..)?
We开发者_运维技巧 are having fun with Redis on a Nodejs server - great combo btw. The question is out of curiosity and should be treated as "in theory".
Is there any performance difference between storing your values on numeric keys (1,2,3,4...) over compressed keys (A9z3,A9z4,A9z5...). I'm thinking select speed only in a database with 2 million keys.
I hope the question is not too damn stupid, best regards ;)
This was answered by antirez on the Google Group. And the answer is no for 2.0 and 2.2:
http://groups.google.com/group/redis-db/browse_thread/thread/305238470e337eb9/c92ae11089541925?lnk=gst#c92ae11089541925
If you are storing the keys as a list or a string, there should be no performance difference, as the integers are stored the same way as strings in memory. So, there would be no noticeable performance difference when selecting a string or an integer.
Memory wise, the compressed keys would have less overhead in memory "because with small keys and values there is a lot of overhead." But we are talking bytes here. (http://redis.io/topics/faq)
Depending on the size of your responses and your query rate, there should be a slight performance gain to using the "compressed" keys in terms of network bandwidth and protocol parsing time.
This would be an interesting and easy thing to verify with a simple test program.
精彩评论