Optimization on number keys

142 views
Skip to first unread message

Jonathan Leibiusky

unread,
Jan 28, 2011, 6:31:39 PM1/28/11
to redi...@googlegroups.com
Hi!
I know that redis optimizes values that are numbers. Does the same
happens with keys?
So if I do:
SET 1232365 456

Does redis store this key as an int rather than the string
representation of this int?

Thanks,

Jonathan

Jeremy Zawodny

unread,
Jan 28, 2011, 6:51:18 PM1/28/11
to redi...@googlegroups.com
Yes.


--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.


Pau Freixes

unread,
Jan 29, 2011, 2:06:20 AM1/29/11
to redi...@googlegroups.com

Sets of just integers will be serializen in "compact" way, and ordered internnally for do more faster lookup opertion

Salvatore Sanfilippo

unread,
Jan 29, 2011, 5:02:42 AM1/29/11
to redi...@googlegroups.com

Actually not, nor 2.0 nor 2.2, for two different reasons:

2.0 -> used redis objects as keys, but did not encoded keys as
integers because we need to perform hasing on keys many many times, so
the CPU cost was too high.
2.2 -> no longer uses redis objects as keys, but plain strings, in
order to save memory. So encoding is completely impossible (and not
desirable).

Another point for not trying key encoding is that data sets where key
names are not prefixed with some kind of non-numeric character are
very rare. Usually you have user:1000 and not 1000.

Cheers,
Salvatore

>
> Thanks,
>
> Jonathan
>
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>
>

--
Salvatore 'antirez' Sanfilippo
open source developer - VMware

http://invece.org
"We are what we repeatedly do. Excellence, therefore, is not an act,
but a habit." -- Aristotele

Reply all
Reply to author
Forward
0 new messages