title: Is it better to query MongoDB a lot or loop a large array
body: <p>If I have a large array of objects/documents to be inserted to MongoDB (with Mongoose). But each object has a property that first needs to be filled. Is it faster to query MongoDB for this property for each document. Or is it better to get one big array and loop that every time.</p>
  
  <p>The query and loop would be very simple and the documents queried are small. The collection (and thus the array) has about 3000 items.</p>
  
  <p>At what point do Mongos indexes, native driver, etc. outweigh the overhead of the queries?</p>
  
  <p>Edit:
  A simple example would be.</p>
  
  <p>I have an array of documents like this.</p>
  
  <pre><code>{
      prop1: 'abc',
      prop2: '123',
      prop3: ''
  }
  </code></pre>
  
  <p>And for the value of <code>prop3</code> I need to query MongoDB to match <code>prop1</code>. Those documents look something like this.</p>
  
  <pre><code>{
      prop1: 'abc',
      prop3: 564
  }
  </code></pre>
  
  <p>There are about 3000 of these second documents. So do I query them or loop an array </p>