user20421644
user20421644

Reputation:

Optimal way of calculating like count on many posts. FullStack

Assume:

i) http page with 'n' user posts. Each post have a like count indicator.

ii) At the backend there is a database with a table 'likes', likes(user_ID, post_ID).

What would be the optimal way of calculating and including these like counts on the http page?

As I see it, you can either calculate all the like counts with multiple db queries and render this into the page before returning the page to the user. Or return the http page without like counts and later via js fetch like count with multiple subsequent requests. Any thoughts on pros and cons, or alternative better ways of doing this is highly appreciated.

Upvotes: 0

Views: 13

Answers (0)

Related Questions