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

Implementing "seen by" functionality with Postgres

Blog post from Supabase

Post Details
Company
Date Published
Author
Victor
Word Count
3,909
Company Posts That Month
3
Language
English
Hacker News Points
1
Post removed?
No
Summary

In this post, we explored four different ways to implement a Postgres-based solution for tracking how many people have seen a particular piece of content. We used the following approaches: 1. simple-counter: A simple counter that increments every time someone sees a post. 2. simple-hstore: Using an HStore field to store the number of times a post has been seen. 3. assoc-table: Storing each view as a row in a table, and querying for the count of rows. 4. hll: Using HyperLogLog to count distinct entries (views). We found that while simple-counter was the fastest solution on average, it had the highest 99.999%ile latency. The HLL approach provided a good balance between performance and accuracy, with an average latency of 2.16ms and a 99.999%ile latency of 27ms. We also discussed some other potential solutions, such as incremental view maintenance powered by pg_ivm and doing graph computations with AGE. While these solutions were not explored in depth, they could be worth considering for future implementations.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.