title: MongoDB most efficient Query Strategy
body: <p>I state that I have already tried to look in the Mongo documentation, but I have not found what I am looking for. I've also read similar questions, but they always talk about very simple queries. I'm working with the Node's Mongo native driver. This is a scalability problem, so the collections I am talking about can have millions of records or some dozen.</p>
  <p>Basically I have a query and I need to validate all results (which have a complex structure). Two possible solutions come to mind:</p>
  <ol>
  <li>I create a query as specific as possible and try to validate the result directly on the server</li>
  <li>I use the cursor to go through the documents one by one from the client (this would also allow me to stop if I am looking for only one result)</li>
  </ol>
  <p>Here is the question: what is the most efficient way, in terms of latency, overall time, bandwidth use and computational weight server/client? There is probably no single answer, in fact I'd like to understand the pros and cons of the different approaches (and whichever approach you recommend). I know the solution should be determined on a case-by-case basis, however I am trying to figure out what could best cover most of the cases.</p>
  <p>Also, to be more specific:</p>
  <ul>
  <li>A) Being a complex query (several nested objects with ranges of values ​​and lists of values ​​allowed), performing the validation from the server would certainly save bandwidth, but is it always possible? And in terms of computation could it be more efficient to do it on the client?</li>
  <li>B) I don't understand the cursor behavior: is it a continuously open stream until it is closed by server/client? In addition, does the <code>next()</code> result already take up resources on the server/client or does it happen to the call?</li>
  </ul>
  <p>If anyone knows, I'd also like to know how Mongoose solved these &quot;problems&quot;, for example in the case of custom validators.</p>