Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using GUID (or similar) has performance penalty in Redis?

Tags:

redis

Does using a GUID or ulong key impact Redis DB performance?

Similar: Does name length impact performance in Redis?

like image 764
Oguz Karadenizli Avatar asked Jun 06 '12 04:06

Oguz Karadenizli


2 Answers

This question is an old one, but other answers are a bit misleading. Eric's answer is totally unrelated to Redis. Pfreixes's answer is based on personal assumptions and is simply wrong.

In fact, it's fairly safe to use GUID keys (performance-wise) as even 300+ character keys don't affect performance significantly on O(1) operations. Check this benchmark: Does name length impact performance in Redis?.

GUID typically has a length of 32-36 chars, if you're using hex representation. As Evan Carrol noticed in comments, Redis strings are binary safe, so you can use binary value and reduce key size down to 128 bits (16 chars). Keys with such length won't hurt performance at all.

Also, documentation suggests to use hashing functions for really large keys: http://redis.io/topics/data-types-intro

like image 101
Max Malysh Avatar answered Oct 05 '22 22:10

Max Malysh


Redis use a hash strategy to store all keys, every key is stored using a hash function. All Redis db peformance about keys fall into this function - or something related.

Original key is also stored to figure out future colisions between diferent keys, and yes big keys could be impact at memory handle and all of related fields : memory fragmentation, cache hits/misses, etc ...

like image 42
pfreixes Avatar answered Oct 05 '22 22:10

pfreixes