pfmerge.3valkey - Man Page

Merges one or more HyperLogLog values into a single key.

Synopsis

PFMERGE destkey sourcekey [sourcekey...]

Description

Merge multiple HyperLogLog values into a unique value that will approximate the cardinality of the union of the observed Sets of the source HyperLogLog structures.

The computed merged HyperLogLog is set to the destination variable, which is created if does not exist (defaulting to an empty HyperLogLog).

If the destination variable exists, it is treated as one of the source sets and its cardinality will be included in the cardinality of the computed HyperLogLog.

Reply

valkey-protocol(7) Simple string reply: OK.

Complexity

O(N) to merge N HyperLogLogs, but with high constant times.

Acl Categories

@hyperloglog @slow @write

History

Examples

127.0.0.1:6379> PFADD hll1 foo bar zap a
(integer) 1
127.0.0.1:6379> PFADD hll2 a b c foo
(integer) 1
127.0.0.1:6379> PFMERGE hll3 hll1 hll2
OK
127.0.0.1:6379> PFCOUNT hll3
(integer) 6

See Also

pfadd(3valkey), pfcount(3valkey), pfdebug(3valkey), pfselftest(3valkey)

Info

2024-09-23 8.0.0 Valkey Command Manual