%3C/text%3E%3C/svg%3E">
💻
💻 Tech & IT

HyperLogLog Error & Memory Calculator

Results update as you type.

Your numbers

Understanding the HyperLogLog error and memory calculator — concept and principle

HyperLogLog (HLL) estimates how many distinct items a data stream contains, such as unique visitors or unique search queries, using a tiny fixed amount of memory. This calculator shows the trade-off at the heart of HLL: the precision p sets the number of registers, which fixes both the memory used and the typical relative error of the estimate.

How HyperLogLog uses its registersThe first 14 hash bits choose one of 16,384 registers, which keeps the longest run of leading zeros; 12 KiB gives a 0.81% standard error.HyperLogLog: count with tiny registershash of an item:000001101110100001011…first 14 bits → register 4423 zeros → value 43524…4…63#4422¹⁴ = 16,384 registers × 6 bits= 98,304 bits ÷ 8 ÷ 1,024= 12 KiB%error ≈ 0.81%1.04 ÷ √16,384 = 1.04 ÷ 128
With p = 14 the sketch uses 12 KiB and counts within about ±0.81%.

How it is calculated

Six bits per register is the usual choice because a register stores a count of leading zeros, which never exceeds 63 for a 64-bit hash.

The principle

Hash every item to a random-looking bit string. Among n random strings, the longest run of leading zeros is about log₂ n, because a run of r zeros has probability 2⁻ʳ. One such maximum is very noisy, so HLL uses the first p bits of the hash to pick one of m registers and keeps the maximum run separately in each. It then combines the registers with a harmonic mean and a correction constant. Averaging m independent estimates shrinks the error in proportion to 1 ÷ √m, and the analysis by Flajolet and colleagues gives the constant 1.04. Duplicates hash to the same value, so they never change the result.

Worked example

  1. Inputs: p = 14, 6 bits per register.
  2. Registers: 2¹⁴ = 16,384; √16,384 = 128.
  3. Standard error: 1.04 ÷ 128 = 0.008125, shown as 0.81%.
  4. Memory: 16,384 × 6 ÷ 8 ÷ 1,024 = 12 KiB.

These are the settings Redis uses for its PFCOUNT command, which its documentation describes as 12 KB with a standard error of 0.81%.

How Standard error changes with Precision p (registers = 2^p)How Standard error changes with Precisio…0102030403.5710.51417.52128Example: 0.81%Precision p (registers = 2^p)
Each point is the calculator re-run with only “Precision p (registers = 2^p)” changed; the gold point is the default example. Change the inputs above and this chart follows your numbers.
Precision p (registers = 2^p)Standard error
3.530.92%
79.19%
10.52.73%
140.81%
17.50.24%
210.07%
280.01%

How to read the result

The standard error is relative: for 10 million true distinct items, 0.81% is about ±81,000. Roughly 68% of estimates fall within one standard error and about 95% within two. Each increase of p by one doubles memory and divides the error by √2 (about 0.71), so going from 12 KiB to 48 KiB only halves the error.

Common mistakes

Keep in mind: The 1.04/√m figure holds for large cardinalities with a good hash. Very small counts use special corrections, and implementations such as HyperLogLog++ change the error profile, so check your library's documentation.

Frequently asked questions

How many items can HLL count?

With a 64-bit hash, far more than any real data set, while memory stays fixed at the size shown.

Can I combine two HLL sketches?

Yes, if they use the same p and hash: take the maximum of each register to get the sketch of the union.

Why not just use a hash set?

A set needs memory proportional to the number of distinct items, which can be gigabytes; HLL needs kilobytes.

Sources: P. Flajolet, É. Fusy, O. Gandouet, F. Meunier, "HyperLogLog: the analysis of a near-optimal cardinality estimation algorithm", AofA 2007 · S. Heule, M. Nunkesser, A. Hall, "HyperLogLog in practice", EDBT 2013 · Redis documentation, HyperLogLog (PFADD, PFCOUNT)

Checked 8 Nov 2026. Standard formulas and RFC/IEEE definitions, computed locally in your browser — nothing you type is sent anywhere.

💻 All tech & IT tools →🌍 Calculators by country →