0

Let's say I am following these user_ids,ex. 1,2,3,4,5

does twitter get the latest tweets with this query ?

select*from tweets where user_id in (select id from user_id)

I am trying to do this now to develop myself, but when I think, it is too much for "in" keyword, so what do you think ?, what might be the other possibilities better than this one?

thank you :)

Stennie
  • 63,885
  • 14
  • 149
  • 175
johna
  • 59
  • 1
  • 1
  • 6
  • Do one query for each followed user id. – simbabque Oct 04 '12 at 20:38
  • but that is more expensive than in, isn't it ? – johna Oct 04 '12 at 20:39
  • You'd have to use in to some extent or another, you could limit the number of users you it loaded if you feel like it's too many. Facebook does something like that with the feed, so you don't see every post by all of your friends, just a subset. – shortstuffsushi Oct 04 '12 at 20:40
  • You would need to benchmark that. – simbabque Oct 04 '12 at 20:40
  • @simbabque That is an awful idea if you're already concerned about pulling too many followers. A single query would typically always be faster than many separate ones, unless you intend to do it asynchronously and merge them elsewhere. – shortstuffsushi Oct 04 '12 at 20:40
  • @shortstuffsushi the OP was asking for alternatives. I wasn't saying it was a good idea. ;-) – simbabque Oct 04 '12 at 20:41

1 Answers1

4

Twitter uses Vector to solve it, more specifically Graph DB perhaps FlockDB. You can learn more about it at http://engineering.twitter.com/2010/05/introducing-flockdb.html

Ravi Kumar
  • 1,382
  • 16
  • 22