As part of research in moving part of our traffic to Fauna, I am looking into our notification feed.
Just to make sure we are on the same page, a notification feed is the screen in many apps that shows a list of top X events that happened, and shows a seen/not seen on each one of them.
Our current implementation using Postgres is a table like this one:
The notification_id column is a forgien key for a table containing the text and other info about the notification. So for example to display the notification feed for user_id 19456, we need to select from table where user_id=19456 and order by row_id desc limit 15, and join it with a notifications table by notification_id.
The notification feed supports this main features:
GetFeed(userId) - Gets the top 15 notifications for a specific user id. To start with, we support fetching only the last 15. Fetching more won’t be possible.
GetCountUnSeen(userId) - Gets the number of unseen notifications. For all the notifications,not just the top 15.
SetSeen(userId, timestamp) - Will set is_seen=true for all the rowsof the userId that are below timestamp.
FanoutNotification(notificationId, [userIds]) - will insert new rows of (notificationId, userId) for each user in the array. The userIds array can be large. For exmaple 400,000.
Can those operations be built with Fauna and perform well? The GetFeed() should be around 500ms since its cllaed from the UI. Regarding FanoutNotification() it could be slower. It’s no problem that it takes 10 min to fanout a notification.
Any help on the subject will be much appreciated.