News

MariaDB HyperLogLog plugin adds distinct count sketches

The type_hll plugin adds a HyperLogLog data type and sketch functions to MariaDB. Currently requires a server built from a development branch, not a stable release.

UptimeMag editorial team · 1 November 2026 · 2 min read

MariaDB: un plugin aggiunge HyperLogLog per i conteggi distinti

Anyone maintaining a count of unique daily users knows the problem: daily figures cannot be summed to get the weekly total, because the same user can appear on multiple days. The classical solution is to rescan the raw logs every time the required time window changes. A new MariaDB plugin, type_hll, attempts to avoid this by shifting the computation onto data structures that can be summed together.

The plugin, described on the official MariaDB blog by Roman Nozdrin, adds a shared library, type_hll.so, which registers the HLL data type and eight functions. It is activated with a single statement: INSTALL SONAME 'type_hll'.

The detail that matters for anyone wanting to try it immediately: until the mechanism officially lands in the server, the plugin requires a server built from this branch, namely from the pull request MariaDB/server#6011, not from a stable package downloadable from the official repository.

What it actually does

An HLL-type column contains a sketch, not an exact count. It is constructed with HLL_BUILD_AGG(column) in a GROUP BY, and different sketches are combined with HLL_UNION_AGG() to answer questions about wider time windows without rescanning the raw data. Precision is not absolute: up to 256 distinct values the count is exact; beyond that threshold, the estimate uses 16384 registers with an expected standard error of approximately 0.8125%, according to the blog post.

The technical mechanism under the hood combines three server APIs: pluggable data types, pluggable scalar functions (both available since 2019), and pluggable aggregate functions, introduced with MDEV-40672. On the official MariaDB changelog, this feature is already listed among the features of the 13.2 Preview series, released on 23 September 2026, and not just "coming with 13.3" as stated in the blog post.

For those evaluating it now

Anyone running MariaDB instances in production will not find this plugin in stable repositories: you need to build the server from the indicated branch. Those who currently need HyperLogLog sketches in production on a relational database can evaluate mature alternatives already available, such as the postgresql-hll extension for PostgreSQL, available for years and packaged up to PostgreSQL 18.

The plugin code and pull request are public on GitHub, in the MariaDB/server repository.

Written with the help of artificial intelligence and checked by the editors (EU AI Act, art. 50).