How big of an array before $in becomes a performance problem?

Say I have three collections Tweets, Users and Follows. If I follow you, I create a Follow record with your _id and my _id. I follow 1,500 people. To search the tweets of the people I follow, I query Tweets with a massive $in query holding an array of 1,500 users _ids.

Am I in trouble?

I just did a test, fetching 200 documents, from a collection of 50.000, using an $in array of 1500 _ids. It only took 150ms, about as long as {id_:{$exists:true}} :slight_smile:

1 Like