title: How does Mongo DB handle a large array field?
body: <p>I'm trying to store a list of ObjectIds in a document as an array field.</p>
  
  <p>I understand Mongo DB has a 4MB size limit for single documents. So considering the length of ObjectId is 12 bytes, a document should be able to handle more than 300,000 entries in one array field. (Let me know if the calculation is off).</p>
  
  <p>If the number of entries in the array gets close to that limit, what kind of performance can I expect? Especially when the field is indexed? Any memory issues?</p>
  
  <p><br /></p>
  
  <p>Typical queries would look like below:</p>
  
  <p><strong>Query by a single value</strong></p>
  
  <pre><code>db.myCollection.find(
    {
      myObjectIds: ObjectId('47cc67093475061e3d95369d')
    }
  );
  </code></pre>
  
  <p><strong>Query by multiple values</strong></p>
  
  <pre><code>db.myCollection.find(
    {
      myObjectIds: {$in: [ObjectId('47cc67093475061e3d95369d'), ...]}
    }
  );
  </code></pre>
  
  <p><strong>Add a new value to multiple documents</strong></p>
  
  <pre><code>db.myCollection.update(
    {
      _id: {$in: [ObjectId('56cc67093475061e3d95369d'), ...]}
    },
    {
      $addToSet: {myObjectIds: ObjectId('69cc67093475061e3d95369d')}
    }
  );
  </code></pre>
  
  <p><br/></p>