Question

I have a newsfeed with comments. I'm storing comments in MongoDB. Newsfeed possibly could grow very large in future so I need high speed.

comments: [
    {user_id: 34, user_name: "John", text: "..."}
]

As you can see, I'm storing info about user as well because Mongo's docs say "when you need speed, use embeds".

But user can change his name anytime. In that case user's name under each of his comments in newsfeed would be wrong.

Should I use references (DBref) to "User" collection by _id instead of embeds? And how much slower would it be? Is that slowdown big enough to be worried about it?

I'm just wondering how all big social networks are doing that. When I change my user's name it instantly updates in all my posts in newsfeed.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top