Hash command performance

336 views
Skip to first unread message

Birdy

unread,
Aug 17, 2012, 8:00:19 AM8/17/12
to redi...@googlegroups.com

We are using Hashes in Redis. Commands used are hget , hset ,hgetall and hdel.  We are using only 1-key to insert into hashes. The size of the hash field is 16-byte and size of hash value is 512 bytes.

Kindly answer the following query.

1. Is there any effect of increase in the number of keys in hash on performance of  hget, hset, hgetall and hdel commands?

2. If the number of hash field in a single key is around 4,00,000, would it have some adverse impact on Redis server’s performance?


Thanks,

Anurag Berdia

Didier Spezia

unread,
Aug 17, 2012, 8:17:05 AM8/17/12
to redi...@googlegroups.com

>> 1. Is there any effect of increase in the number of keys in hash on performance of  hget, hset, hgetall and hdel commands?

hget is O(1), hset and hdel are also O(1) (provided only one key is considered).
You can consider the performance of these commands are not impacted by the size of the hash object.

hgetall is O(N) - so its performance is linear with the number of keys.
Retrieving a very large hash object with hgetall may block a Redis server for several seconds.

>> 2. If the number of hash field in a single key is around 4,00,000, would it have some adverse impact on Redis server’s performance?

Rehashing occurs in background, so if you avoid executing O(N) commands on the hash object,
a Redis instance can support it with no issue.

Regards,
Didier.
Reply all
Reply to author
Forward
0 new messages