Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

PFMERGE

Last updated
PFMERGE destkey [sourcekey [sourcekey ...]]
Group
HyperLogLog
Complexity
O(N) for N source keys
Arity
-2 (at least 2 words, counting the command name)
Flags
write
Keys
first 1, last final argument, step 1
HotKV Cloud
All plans
On-Premise
no license needed

PFMERGE combines the source HyperLogLogs into destkey, so that its estimate covers every element seen by any of them. If destkey already holds a HyperLogLog, it is part of the union too; otherwise it is created. Missing sources are skipped. With no sources, PFMERGE just makes sure destkey exists as a HyperLogLog. The destination keeps its time to live.

In a cluster, all keys must hash to the same slot.

Case RESP2 RESP3
Always Simple string OK Simple string OK

The errors are those of PFADD, for the destination or any source.

127.0.0.1:6379> PFADD day:1 alice bob carol
(integer) 1
127.0.0.1:6379> PFADD day:2 carol dave
(integer) 1
127.0.0.1:6379> PFMERGE week day:1 day:2
OK
127.0.0.1:6379> PFCOUNT week
(integer) 4

Same as Redis 7 and Valkey 8.

PFADD, PFCOUNT