validate( true )
Validates a collection. The method scans a collection data and indexes for correctness and returns the result. For details of the output, see Validate Output.
db.collection.validate()method has the following syntax:
To specify the
fulloption, you can also use:
db.collection.validate()method can take the following optional document parameter with the fields:
Field Type Description
Optional. A flag that determines whether the command performs a slower but more thorough check or a faster but less thorough check.
true, performs a more thorough check.
false, omits some checks for a fater but less thorough check.
The default is
Starting in MongoDB 3.6, for the WiredTiger storage engine, only the
fullvalidation process will force a checkpoint and flush all in-memory data to disk before verifying the on-disk data.
In previous versions, the data validation process for the WT storage engine always forces a checkpoint.
db.collection.validate() method is potentially resource intensive and may impact the performance of your MongoDB instance.
db.collection.validate() method obtains an exclusive lock on the collection. This will block all reads and writes on the collection until the operation finishes. When run on a secondary, the operation can block all other operations on that secondary until it finishes.
db.collection.validate() method can be slow, particularly on larger data sets.
Due to the manner in which
validate scans data structures, even a full collection validation cannot detect all forms of corruption on MMAPv1 storage engine data files.
To validate a collection
myCollectionusing the default settings (i.e.
To peform a full validation of a collection
For details of the output, see Validate Output.