Skip to content

Instantly share code, notes, and snippets.

@musukvl
Created November 2, 2017 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save musukvl/997f1eca1f8f8fd42d3ef8ca7903bf4d to your computer and use it in GitHub Desktop.
Save musukvl/997f1eca1f8f8fd42d3ef8ca7903bf4d to your computer and use it in GitHub Desktop.
MongoDB function to create 100 000 documents
db.system.js.save({
_id: "test",
value: function () {
var start = new Date();
for (var i = 1; i <= 100000; i++) {
db.getCollection('log').insert({
"key": (new ObjectId()).toString(),
"data": "some random data: " + (new ObjectId()).toString(),
"updated_date": new Date()
})
}
return new Date() - start;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment