tamanho de dados
Definição
dataSize
The
dataSize
command returns the size in bytes for the specified data.
Compatibilidade
Esse comando está disponível em implantações hospedadas nos seguintes ambientes:
MongoDB Atlas: o serviço totalmente gerenciado para implantações do MongoDB na nuvem
Importante
Esse comando não é suportado em clusters M,0 M,2 M5 e Flex. Para obter mais informações, consulte Comandos não suportados.
MongoDB Enterprise: a versão autogerenciada e baseada em assinatura do MongoDB
MongoDB Community: uma versão com código disponível, de uso gratuito e autogerenciada do MongoDB
Sintaxe
O comando tem a seguinte sintaxe:
db.runCommand( { dataSize: <string>, keyPattern: <document>, min: <document>, max: <document>, estimate: <boolean> } )
Campos de comando
O comando utiliza os seguintes campos:
Campo | Tipo | Descrição |
---|---|---|
| string | O nome da coleção de destino. |
| documento | Optional. The collection's key pattern to examine. The collection must have an index with the corresponding pattern.
Otherwise |
| documento | Optional. The lower bound of the key range to be examined. |
| documento | Optional. The upper bound of the key range to be examined. |
| booleano | Optional. When Defaults to false. |
Exemplo
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}
.
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.
The amount of time required to return dataSize
depends on the
amount of data in the collection.