Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb $in limit [duplicate]

Tags:

mongodb

Was just wondering if there is a limit to Mongodb's $in function?

http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24in

I have a collection of users (BIG) and have a smaller subset of ObjectIds stashed somewhere, and I want to select all users (collections) that are in my ObjectIds.

Thanks

like image 514
poxion Avatar asked Jul 03 '12 05:07

poxion


People also ask

How do I restrict duplicates in MongoDB?

To insert records in MongoDB and avoid duplicates, use “unique:true”.

Does MongoDB allow duplicates?

While you cannot prevent entries with duplicated data. You can query/aggregate the data in such a way that replicated data is ignored. On the same $group stage you could pick up the max, min, avg etc for a given entry.

How do I limit a record in MongoDB?

To limit the records in MongoDB, you need to use limit() method. The method accepts one number type argument, which is the number of documents that you want to be displayed.

What is the maximum number of parameters passed to $IN query in MongoDB?

THE ANSWER: 1,525,198 (That's 1.5 million.


1 Answers

Since there's no limit on the number of items in an array as such, you shouldn't have any problem.. For the case when the array is embedded inside a document, you might want to have a look at these:

http://groups.google.com/group/mongodb-user/browse_thread/thread/4a7caeba972aa998?fwc=1

Filtering content based on words

http://groups.google.com/group/mongodb-user/browse_thread/thread/28ae76e5ad5fcfb5

like image 111
Aafreen Sheikh Avatar answered Nov 04 '22 09:11

Aafreen Sheikh