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 ;)
Redis can handle up to 2^32 keys, and was tested in practice to handle at least 250 million keys per instance. Every hash, list, set, and sorted set, can hold 2^32 elements. In other words your limit is likely the available memory in your system.
Redis Keys are Ideal for Keeping Track of Lots of Strings. For the (simple string) key-value data type Redis allows you to set, get, delete, and increment arbitrary string <key, value> pairs. You can only have 1 value at a time for each key (i.e. set is destructive assignment). You can also delete keys.
The first command you can use to get the total number of keys in a Redis database is the DBSIZE command. This simple command should return the total number of keys in a selected database as an integer value. The above example command shows that there are 203 keys in the database at index 10.
Redis stores integers in their integer representation, so for string values that actually hold an integer, there is no overhead for storing the string representation of the integer.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With