I’m about to write simple news feed on Fauna.
Its just list all posts from people i follow.
Ideas that i had to solve it would be:
- Store references of following users in documents. (fan out on write)
- Store Follower-Followee relation, get all followees by user then get index: documents_by_followees
- Store followees in user profile in one array field then query documents_by_followees with array from that field
My understanding is that for relation example if person follows 1000 others then Union would require 1000 read-ops for query.
The normalized version (first idea) would require 1 read but each document that is followed by 1000 people would be - assuming that one ref is 30bytes
1000 * 30 bytes =30 kilobytes
So Which is the best cost wise? What are other ways to approach it?