I have many index in Redis who store key name associated with their timestamp (it's a zset) imagine I have 5 index :
- Apple -> 1 , 2 , 3
- Red -> 1, 2
- green -> 3
- big -> 3 , 2
- small -> 1
I want to know how many Red Apple are big (I can accept a little error margin if it's necessary) the first approach is to intersect apple and red indexes then search 1 and 2 in big but this is resources hungry for big index and if i want to know this for many other index imagine I have 100 index containing 1000 keys, it's impossible in term of speed
second approach are to store for each index a "chain" of index for example when I add a new key, i have access to my key characteristic so i know it's a red small apple, when i add it in Apple i store this information in Apple:Chain = {small -> 1, red -> 1} and then when I have others keys , either I increment existing key or I create a new one, but when i want to know how many red apple are big my chain don't work anymore, because i don't have capability to intersect chain, or i must intersect apple and red then make a chain of the intersect but it's even worst in term of speed compared to the first approach
third approach seem to be approximation of the result, how can i approximatively know how many red apple are big with a reasonable margin of error ? i see Redis have HyperLogLog can i use it for this purpose ?
and finally if you see another approach tell me, even if i had to store another data structure or change the existing one , I'm open to all suggestion