1

In my app, users can block other users. There will be queries where I will need to find

$in: [use_id_x, array_that_contains_all_blocked_user_ids]

At what length of array_that_contains_all_blocked_user_ids will this operation become slow.

If it is expected that a user can block up to block 100,000 users, how can I design my schema such that this operation will scale?

  • If its an array that must no exceeds 16mb of doc size if it exceeds working set leads to drop query performance . alternative to this extended reference pattern – Naveen Jan 26 '23 at 07:03

1 Answers1

1

Can't find any things in official doc of $in(aggregation).

However, in official doc of $in, it stated that:

It is recommended that you limit the number of parameters passed to the $in operator to tens of values. Using hundreds of parameters or more can negatively impact query performance.

My interpretation is that the official recommendation is below 100. But at the end, I think it depends on what is "slow" to you, and that highly depends on your actual scenario like system specs, and performance requirements...

ray
  • 11,310
  • 7
  • 18
  • 42