Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3451

Performance-Regression - Find/Create is significantly slower in 4.0.0 compared to 3.6.9

    • 5
    • Not Needed

      MongoDB is initialized as ReplicationSet.

      Performance-Regression for simple Find/Create Operation. Just change the used MongoDB-Version between 3.6.9 and 4.0.0 and run the script.

      My Results:
      3.6.9:
      create: 11.380s
      find - toArray: 1.913s
      find - cursor: 2.827s
      delete: 16.908s

      4.0.0:
      create: 16.860s
      find - toArray: 2.613s
      find - cursor: 5.485s
      delete: 17.078s

      --> Create is ~50% slower
      --> Find is nearly 100% slower

      Testcode:

      Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      import { MongoClient } from "mongodb";
      
      async function main(): Promise<void> {
          const client = new MongoClient(`mongodb://localhost:27017/`, {});
          await client.connect();
      
          const files = [];
          for (let i = 0; i < 1000000; i++){
              files.push({a: i, b: i, c: i, d: i});
          }
          console.time("create");
          await client.db("test").collection("test").insertMany(files);
          console.timeEnd("create");
      
          console.time("find - toArray");
          await client.db("test").collection("test").find({}, {projection: {_id: 1}}).toArray();
          console.timeEnd("find - toArray");
      
          console.time("find - cursor");
          for await(const _ of client.db("test").collection("test").find({})) {
          }
          console.timeEnd("find - cursor");
      
          console.time("delete");
          await client.db("test").collection("test").deleteMany({});
          console.timeEnd("delete");
      
          await client.db("test").dropDatabase();
          process.exit();
      
      }
      
      main().catch(console.error)
      

            Assignee:
            daria.pardue@mongodb.com Daria Pardue
            Reporter:
            haser@videmo.de Yannick Haser
            Neal Beeken
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: