Redis › HyperLogLog in Redis

How would you design an analytics system using HyperLogLog to track unique visitors across multiple time periods, such as daily, weekly, and monthly counts?

Advanced

Answer

You would create a separate HyperLogLog for each day, add visitor identifiers to the appropriate day's structure as they occur, and then use PFMERGE to combine the relevant daily structures into weekly or monthly HyperLogLogs whenever those aggregated counts are needed, avoiding the need to reprocess raw visitor data for every different time period you want to report on.
PFADD visitors:2026-09-07 'user123'
PFMERGE visitors:week36 visitors:2026-09-01 visitors:2026-09-02 -- and so on
Real-world example A media company tracks daily unique visitor HyperLogLogs throughout the month, merging them into weekly and monthly rollups on demand, giving their analytics team flexible reporting across multiple time granularities without reprocessing raw visitor logs.

Common follow-ups: How long should individual daily HyperLogLog structures be retained before being cleaned up?;Does this approach introduce any additional error compared to counting directly over the full time period?