# HyperLogLog Unions

DevFeed: [HyperLogLog Unions](<https://devfeed.tech/articles/hyperloglog-unions-34492.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2013/02/hyperloglog-unions/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2013-02-26T11:44:00Z

Content type: article

Language: en

Sources: [Dimitri Fontaine](<https://devfeed.tech/sources/dimitri-fontaine.md>)

Topics: [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [data](<https://devfeed.tech/topics/data.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [article](<https://devfeed.tech/tags/article.md>), [cardinality](<https://devfeed.tech/tags/cardinality.md>), [data-structure](<https://devfeed.tech/tags/data-structure.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

This article explains how PostgreSQL's HyperLogLog extension maintains a fixed-size data structure for estimating cardinality and supports union operations for counting unique values across sets, including use through SQL aggregates and window functions.

## Source excerpt

In the article from yesterday we talked about PostgreSQL HyperLogLog with some details. The real magic of that extension has been skimmed over though, and needs another very small article all by itself, in case you missed it. *Which Set Operation do you want for counting unique values?* The first query here has the default level of magic in it, really. What happens is that each time we do an update of the HyperLogLog hash value, we update some data which are allowing us to compute its cardinality.