skip to Main Content

I’m writing an api in nodejs and I’m trying to figure out how twitter and facebook shows posts from only the people that we follow.. My initial thought was loop through the posts and filter them according to followers ID, but that consumes a lot of CPU because we’ve to the loop through all the posts in the MySQL DB. What is the correct logic to show only the tweets/posts from the subscribed people/friends

I would be grateful if someone could through some light.

2

Answers


  1. You don’t have to loop through all of them. You have the IDs of your friends, you can call directly to them.

    Now I’m not sure if Indexes are being used in this scenario, but I’d personally use them.

    Login or Signup to reply.
  2. Isn’t this what you want?

    https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline.html

    Just remove your posts from the result set.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search