3 ms·
Not sure about this specific implementation but normally you handle this with approximations that support merging. i.e HyperLogLog You can merge 2 HyperLogLog c
by jpgvm 5y ago
Not sure about this specific implementation but normally you handle this with approximations that support merging. i.e HyperLogLog
You can merge 2 HyperLogLog counters to maintain proper distinct counts.
- arriu 5y agoAwesome, thank you!
- mfreed 5y agoYep! And in fact, that's exactly what TimescaleDB supports - things like hyperloglog to support approximate count distinct, including as part of continuous aggregates. [0] This blog post - "How PostgreSQL aggregation works and how it inspired our hyperfunctions’ design" - provides a really nice description of how our the API design of some of our analytical functions are motivated by the ability to "split" processing into the "pre-aggregation" and "finalization" steps, with the blog post focusing on the example of percentile approximation. (I think it was on HN a while back as well.) [1] [0] https://blog.timescale.com/blog/introducing-hyperfunctions-new-sql-functions-to-simplify-working-with-time-series-data-in-postgresql/ https://blog.timescale.com/blog/introducing-hyperfunctions-n... [1] https://blog.timescale.com/blog/how-postgresql-aggregation-works-and-how-it-inspired-our-hyperfunctions-design-2/ https://blog.timescale.com/blog/how-postgresql-aggregation-w...