title: Official Javascript MongoDB driver is slower than Python PyMongo for the same query?
body: <p>I've been trying out Javascript for my new backend, but I noticed something odd. When I use Python's PyMongo library, fetching all my data runs twice as fast (33.5s -&gt; 16.44s) as when I use the official Javascript MongoDB module. The test setups are as follows:</p>
  <pre class="lang-py prettyprint-override"><code>mongo = MongoClient(URI) # initializing client
  
  rn = time() # starting timer
  for ID in LIST_OF_IDS:
      results = mongo[&quot;current_day_info&quot;][ID].find() # fetches all the documents in the collection named &lt;ID&gt;
      results = [[result[&quot;time&quot;].timestamp() / 10, result[&quot;buy_price&quot;], result[&quot;sell_price&quot;], result[&quot;buy_volume&quot;], result[&quot;sell_volume&quot;], result[&quot;week_buy_amount&quot;], result[&quot;week_sell_amount&quot;]] for result in results] # expands list of documents into array of their values
  print(&quot;mongodb&quot;, time()-rn) # ending timer
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>const client = new MongoClient(URI); // initializing client
  
  async function main() {
      await client.connect(); // connecting to client
      const database = client.db(&quot;current_day_info&quot;); // goes to proper database
  
      console.time(&quot;mongodb&quot;); // starting timer
      for (let ID of LIST_OF_IDS) {
          let results = [];
          const documents = database.collection(ID).find({}); // fetches all the documents in the collection named &lt;ID&gt;
          documents.forEach(item =&gt; results.push([new Date(item.time).getTime(), item.buy_price, item.sell_price, item.buy_volume, item.sell_volume, item.week_buy_amount, item.week_sell_amount])); // expands list of documents into array of their values
      }
      console.timeEnd(&quot;mongodb&quot;); // ending timer
  }
  
  main();
  </code></pre>
  <p>My best guess is that PyMongo has some parts written in C, but I wouldn't think that results in such a drastic increase?</p>
  <p>Versions:
  Python 3.8.10, PyMongo 4.0.2, MongoDB version 5.0.6, MongoDB Node Driver version 4.4.1, NodeJS version 17.7.1</p>
  <hr />
  <p><em><strong>Copied from comments below:</strong></em></p>
  <p>Example document:</p>
  <pre><code>{
     &quot;time&quot;:&quot;ISODate(&quot;&quot;2022-03-12T23:23:45.000Z&quot;&quot;)&quot;,
     &quot;_id&quot;:&quot;ObjectId(&quot;&quot;622d2b8c83d4c06e792895cb&quot;&quot;)&quot;,
     &quot;buy_volume&quot;:2079625,
     &quot;sell_price&quot;:5.5,
     &quot;sell_volume&quot;:10210328,
     &quot;week_sell_amount&quot;:68184205,
     &quot;week_buy_amount&quot;:10783950,
     &quot;buy_price&quot;:7.4
  }
  </code></pre>
  <p>Also, tried the same in MongoSH and it took significantly longer (7 minutes) I assume I messed something up there:</p>
  <pre><code>async function main() { 
      console.time(&quot;mongodb&quot;);
      for (let ID of LIST_OF_IDS) {
          let results = [];
          const collection = db[ID];
          await collection.find({}).forEach((item) =&gt; results.push([cut for charlimit]));
      }
      console.timeEnd(&quot;mongodb&quot;); 
  }
  </code></pre>