---
title: "Discussion on \"Why Your Database Hates COUNT(DISTINCT) and Why HyperLogLog is the Cure\" | Hashnode"
description: "Discussion on \"Why Your Database Hates COUNT(DISTINCT) and Why HyperLogLog is the Cure\". Avoid the memory explosion of COUNT(DISTINCT) at scale. Use the coin-flipping math of HyperLogLog to estimate millions of unique views with constant space."
url: "https://hashnode.com/posts/why-your-database-hates-count-distinct-and-why-hyperloglog-is-the-cure/69bac7d98c55d6eefb313c7c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Why Your Database Hates COUNT(DISTINCT) and Why HyperLogLog is the Cure](https://doogal.dev/why-your-database-hates-count-distinct-and-why-hyperloglog-is-the-cure?utm_source=hashnode&utm_medium=feed)

Avoid the memory explosion of COUNT(DISTINCT) at scale. Use the coin-flipping math of HyperLogLog to estimate millions of unique views with constant space.

Mar 18 · 4 min read · doogal.dev  
Read the article

-   [#algorithms](https://hashnode.com/tag/algorithms)
-   [#backendengineering](https://hashnode.com/tag/backendengineering)
-   [#systemdesign](https://hashnode.com/tag/systemdesign)
-   [#performance](https://hashnode.com/tag/performance)
-   [#probabilisticdatastructures](https://hashnode.com/tag/probabilisticdatastructures)

## Written by

[Doogal Simpson](https://hashnode.com/@doogal)

@doogal

  
[View profile](https://hashnode.com/@doogal)

"hey doogal, what is .... ?"

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
