Navigation

db.collection.validate()

On this page

Description

db.collection.validate(true)

Validates a collection. The method scans a collection’s data structures for correctness and returns a single document that describes the relationship between the logical collection and the physical representation of the data.

The validate() method has the following parameter:

Parameter Type Description
full boolean

Optional. Specify true to enable a full validation and to return full statistics. Full validation is a potentially resource-intensive operation.

Changed in version 3.6: Starting in MongoDB 3.6, for the WiredTiger storage engine, only the full validation 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.

The db.collection.validate() method output provides an in-depth view of how the collection uses storage. Be aware that this command is potentially resource intensive and may impact the performance of your MongoDB instance.

The db.collection.validate() method is a wrapper around the validate database command.

Behavior

db.collection.validate() 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 sblock all other operations on that secondary until it finishes.

See also

validate