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?
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...