Skip to content

Instantly share code, notes, and snippets.

@leifwalsh
Last active August 29, 2015 13:56
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 leifwalsh/9212664 to your computer and use it in GitHub Desktop.
Save leifwalsh/9212664 to your computer and use it in GitHub Desktop.
// RSS
db.runCommand({touch: 'bar', data: true, index: true})
// db.stats() storageSize
(db.stats().storageSize + db.stats().indexSize) / 1024 / 1024 // mongodb
(db.stats().storageSize + db.stats().indexStorageSize) / 1024 / 1024 // tokumx
// full collection count
Date.timeFunc(function() { db.bar.count() }, 100)
// 10-key range count, with matcher
Date.timeFunc(function() { var x = Math.floor(Math.random() * (1000000 - 10)); db.bar.find({a: {$gte: x, $lt: x + 10}, x: 10000}).count() }, 10000)
// 100-key range count, with matcher
Date.timeFunc(function() { var x = Math.floor(Math.random() * (1000000 - 100)); db.bar.find({a: {$gte: x, $lt: x + 100}, x: 10000}).count() }, 10000)
// 1000-key range count, with matcher
Date.timeFunc(function() { var x = Math.floor(Math.random() * (1000000 - 1000)); db.bar.find({a: {$gte: x, $lt: x + 1000}, x: 10000}).count() }, 10000)
// 10000-key range count, with matcher
Date.timeFunc(function() { var x = Math.floor(Math.random() * (1000000 - 10000)); db.bar.find({a: {$gte: x, $lt: x + 10000}, x: 10000}).count() }, 10000)
// 10-key range count, without matcher
Date.timeFunc(function() { var x = Math.floor(Math.random() * (1000000 - 10)); db.bar.find({a: {$gte: x, $lt: x + 10}}).count() }, 10000)
// 100-key range count, without matcher
Date.timeFunc(function() { var x = Math.floor(Math.random() * (1000000 - 100)); db.bar.find({a: {$gte: x, $lt: x + 100}}).count() }, 10000)
// 1000-key range count, without matcher
Date.timeFunc(function() { var x = Math.floor(Math.random() * (1000000 - 1000)); db.bar.find({a: {$gte: x, $lt: x + 1000}}).count() }, 10000)
// 10000-key range count, without matcher
Date.timeFunc(function() { var x = Math.floor(Math.random() * (1000000 - 10000)); db.bar.find({a: {$gte: x, $lt: x + 10000}}).count() }, 10000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment