integers stored as binary data vs string representation

66 views
Skip to first unread message

grdmitro

unread,
Oct 5, 2011, 6:02:44 AM10/5/11
to Redis DB
I'm doing ZUNIONSTORE on huge number(>300k) of small sorted sets(<20
elements) composed of integer elements.
I just tried storing those integers in binary form instead of string
rep and it actually slowed things down significantly. zunionsore that
took 14sec hangs for a long time now.

any ideas why? my intent was obvious: less bytes -> faster comparison -
> faster sets ops

grdmitro

unread,
Oct 5, 2011, 6:04:28 AM10/5/11
to Redis DB
forgot to mention, I'm using redis-2.4.0-rc8 32/64 bit builds

Salvatore Sanfilippo

unread,
Oct 5, 2011, 6:05:15 AM10/5/11
to redi...@googlegroups.com
On Wed, Oct 5, 2011 at 12:02 PM, grdmitro <grdm...@gmail.com> wrote:

> any ideas why? my intent was obvious: less bytes -> faster comparison -
>> faster sets ops

Hello, Redis has internal optimizations that let it understand that a
string can be actually represented by an integer. When it does this it
can do operations (especially comparisons) much faster, leading to
better results, and better memory usage figures.

Cheers,
Salvatore

--
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

grdmitro

unread,
Oct 5, 2011, 6:09:56 AM10/5/11
to Redis DB
thanks! that makes sense now :)
Reply all
Reply to author
Forward
0 new messages