Need some expert suggestions on using '$in' while performing 'update' in mongodb collections. Here is an example:
db.users.update({userid: {$in: ['1','2','3']}}, {$inc: {mycounter: 1}}, false, true);
is it better to use '$in' in this scenario? Also can anyone guide me if there is any limit for array count/size for '$in' in my above scenario it might be 10k+ user ids per update..
Thank you.
Ran the following simple test from the shell:
Performance was reasonable, seems like it can handle 10k simultaneous updates.
I can't find any indication that there's a hard limit on the array size. I think you can apply a "reasonable" limit here though. Even if you can issue commands of with an array of 100k, that's going to be difficult to track.
Some drivers also allow for bulk update commands, which may be more appropriate for what you're doing.