Database Reference
In-Depth Information
"lastExtentDetails" : {
"loc" : "0:2b9000",
"xnext" : "null",
"xprev" : "0:b9000",
"nsdiag" : "blog.posts",
"size" : 8388608,
"firstRecord" : "0:2b90b0",
"lastRecord" : "0:6ec830"
},
"deletedCount" : 4,
"deletedSize" : 3983552,
"nIndexes" : 2,
"keysPerIndex" : {
"blog.posts.$_id_" : 29997,
"blog.posts.$Author_1" : 29997
},
"valid" : true,
"errors" : [ ],
"warning" : "Some checks omitted for speed. use {full:true} option to do more thorough scan.",
"ok" : 1
}
The preceding example takes about 30 seconds to complete. By default, the validate option checks both the
datafiles and the indexes, and it provides some statistics about the collection when it completes. The option will
tell you if there are any problems with either the datafiles or the indexes, but it will not examine every document for
correctness. If examining every document is what you want, then you can run (as suggested in the output) validate
with the {full: true} option, which is invoked by adding the true argument to the function call, as shown here:
db.posts.validate(true) .
You can also use the validate option if you have a very large database and you want only to validate the indexes.
There is no shell helper command for this in the current version (2.6.0). But that isn't an impediment, as you can
readily accomplish this index validation using the runCommand option:
$mongo
>use blog
>db.runCommand({validate:"posts", scandata:false})
In this case, the server does not scan the datafiles; instead, it merely reports the information stored about
the collection.
Repairing Collection Validation Faults
If running validation on your collections turns up an error, which would be noted in the errors section of the
validate document, you have several options for repairing the data. Again, it's impossible to overstress the
importance of having good backups. Before jumping straight into restoring your backup, you should look into the
MongoDB instance's logs to see if there is any additional information about the nature of the error; if so, this should
inform the next steps you take.
 
Search WWH ::




Custom Search