PFMERGE(3valkey)
β¨ PFMERGE β¨
okay so bestie, welcome to the PFMERGE page of the valkey command manual β it's giving "let's smash a bunch of HyperLogLogs together and see who shows up" π
πΈ NAME πΈ
pfmerge β merges one or more HyperLogLog values into a single key. no cap, that's the whole job. π«Ά
π SYNOPSIS π
PFMERGE destkey sourcekey [sourcekey...]
π DESCRIPTION π
So here's the tea: you take a bunch of HyperLogLog values and you merge them into one unique value that approximates the cardinality of the union of all the observed Sets inside those source HyperLogLog structures. it's literally the friendship-merge of HLLs. π¦
The merged HyperLogLog that comes out gets set to the destination variable, and if that destination doesn't exist yet? it just gets created (defaulting to an empty HyperLogLog, iconic behavior honestly). β¨
And the plot twist β if the destination variable does already exist, it gets treated as one of the source sets too, and its cardinality gets counted into the final computed cardinality. so your destkey is not just a passenger, it's a main character. π
π REPLY π
valkey-protocol(7) Simple string reply: OK.
like, that's it. that's the reply. OK. slay.
π₯ COMPLEXITY π₯
O(N) to merge N HyperLogLogs, but with high constant times. so it's linear, but it's linear with vibes, you feel me π
π ACL CATEGORIES π
@hyperloglog@slow@write
π¦ HISTORY π¦
- Available since:
2.8.9
she's been around for a minute, ngl. vintage queen. π
π 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 how hll3 ate and left no crumbs? 6 unique-ish things, merged, done. π
β SEE ALSO β
okay bye bestie, go merge something π
this was PFMERGE(3valkey), page for the valkey command manual, version 9.0.0, dated 2025-10-21 β mwah, love u, read the other HLL pages π«Άβ¨
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms