我正在使用node.js mongodb本机驱动程序,我有一个包含大量文档的集合,如:
{
name: "cat",
}
我有一个查询,我试图测试速度:
collection.find({name: { $gt: 'ca', $lt: 'cb' } }).explain(function(err, docs){
console.log( docs );
});
但是毫秒总是0
{ cursor: 'BasicCursor',
isMultiKey: false,
n: 2,
nscannedObjects: 8,
nscanned: 8,
nscannedObjectsAllPlans: 8,
nscannedAllPlans: 8,
scanAndOrder: false,
indexOnly: false,
nYields: 0,
nChunkSkips: 0,
millis: 0,
allPlans:
[ { cursor: 'BasicCursor',
isMultiKey: false,
n: 2,
nscannedObjects: 8,
nscanned: 8,
scanAndOrder: false,
indexOnly: false,
nChunkSkips: 0 } ],
server: 'h003723.mongolab.com:33453',
filterSet: false,
stats:
{ type: 'COLLSCAN',
works: 10,
yields: 0,
unyields: 0,
invalidates: 0,
advanced: 2,
needTime: 7,
needFetch: 0,
isEOF: 1,
docsTested: 8,
children: [] } }
我似乎无法弄清楚这一点,显然我不能像这样测试这个查询,我错过了什么吗?