dataSize

On this page本页内容

Definition定义

dataSize

The dataSize command returns the size in bytes for the specified data:dataSize命令返回指定数据的大小(以字节为单位):

{
   dataSize: <string>,
   keyPattern: <document>,
   min: <document>,
   max: <document>,
   estimate: <boolean>
}

The command takes the following fields:该命令接受以下字段:

Field字段Type类型Description描述
dataSizestringThe 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 dataSize returns an error message.否则,dataSize返回错误消息。

mindocumentOptional. 可选。The lower bound of the key range to be examined.要检查的密钥范围的下限。
maxdocumentOptional. 可选。The upper bound of the key range to be examined.要检查的密钥范围的上限。
estimateboolean

Optional. 可选。When true, dataSize estimates the data size by assuming that all documents in the specified range are uniformly sized as per the collection's average object size. 如果为truedataSize通过假设指定范围内的所有文档都按照集合的平均对象大小一致性大小来估计数据大小。The collection's average object size is obtained from the avgObjSize field in the output of the collStats command.集合的平均对象大小是从collStats命令输出中的avgObjSize字段获得的。

Defaults to false.默认为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}.以下操作在dataSize集合上运行dataSize命令,指定键模式{field: 1},要检查的键范围的下限为{field: 10},而要检查的密钥的上限为{field: 100}

db.runCommand({ dataSize: "database.collection", keyPattern: { field: 1 }, min: { field: 10 }, max: { field: 100 } })

This returns a document with the size in bytes for all matching documents. 这将返回所有匹配文档的大小为字节的文档。Replace database.collection with the database and collection from your deployment.database.collection替换为部署中的数据库和集合。

The amount of time required to return dataSize depends on the amount of data in the collection.返回dataSize所需的时间取决于集合中的数据量。

←  cursorInfodbHash →