- Reference >
- Database Commands >
- Diagnostic Commands >
- dataSize
dataSize¶
On this page
Definition¶
-
dataSize¶ The
dataSizecommand returns the data size for a set of data within a certain range:The command takes the following fields:
Field Type Description dataSizestring The name of the target collection. keyPatterndocument Optional. The collection’s key pattern to examine.
The collection must have an index with the corresponding pattern. Otherwise
dataSizereturns an error message.mindocument Optional. The lower bound of the key range to be examined. maxdocument Optional. The upper bound of the key range to be examined. estimateboolean Optional. When
true,dataSizeestimates the data size by assuming that all documents in the specified range are uniformly sized as per the collection’s average object size. The collection’s average object size is obtained from theavgObjSizefield in the output of thecollStatscommand.Defaults to false.
Example¶
The following operation runs the dataSize command on the
database.collection collection, specifying a key pattern of {field: 1}
with the lower bound of the range of keys to be examined being {field: 10}
and the upper bound of the key to be examined being {field: 100}.
This will return a document that contains the size of all matching
documents. Replace database.collection value with database
and collection from your deployment.
The amount of time required to return dataSize depends on the
amount of data in the collection.