MongoDB 验证命令(Validate Command)
这个命令会扫描整个collection和它的索引并且数据集较大的时候,这个过程是非常缓慢的。
MongoDB Shell执行:
> db.foo.validate()
{"ns" : "test.foo" , "result" : "validate details: 08D03C9C ofs:963c9c firstExtent:0:156800 ns:test.foo lastExtent:0:156800 ns:test.foo # extents:1 datasize?:144 nrecords?:3 lastExtentSize:2816 padding:1 first extent: loc:0:156800 xnext:null xprev:null ns:test.foo size:2816 firstRecord:0:1568b0 lastRecord:0:156930 3 objects found, nobj:3 192 bytes data w/headers 144 bytes data wout/headers deletedList: 0000000100000000000 deleted: n: 1 size: 2448 nIndexes:1 test.foo.$x_1 keys:3" , "ok" : 1 , "valid" : true , "lastExtentSize" : 2816}
从驱动调用的话,会执行如下语句:
> db.$cmd.findOne({validate:"foo" } );
validate?会有个scandata 参数 会跳过扫描基本的collection(但是仍然扫描索引).
> db.$cmd.findOne({validate:"foo", scandata:true});