Home / Companies / Tinybird / Blog / Post Details
Content Deep Dive

The simplest way to count 100B unique IDs: Part 2

Blog post from Tinybird

Post Details
Company
Date Published
Author
Ariel Perez
Word Count
1,070
Language
English
Hacker News Points
-
Summary

As the number of views on posts increases to trillions, simple systems for counting unique viewers become insufficient, prompting the need for scalable solutions. The challenges arise from the sheer volume of data and the limitations of functions like uniqExact, which, while providing perfect accuracy, can lead to significant performance degradation due to memory and CPU constraints. To address these issues, optimizations such as using uniqCombined64, which adapts based on data scale, and pre-aggregation with materialized views are proposed. These methods help manage memory usage and improve query performance, with uniqCombined64 offering a balance between accuracy and scalability, and pre-aggregation reducing query times by maintaining exact counts in real-time. A combined approach utilizing both uniqCombined64 and pre-aggregation is recommended for handling massive scale while ensuring efficient resource use, enabling teams to maintain performance without sacrificing accuracy significantly.