Para agentes de IA: um índice de documentação está disponível em https://www.mongodb.com/pt-br/docs/llms.txt — as versões de markdown de todas as páginas estão disponíveis anexando .md a qualquer caminho de URL.
Menu Docs

dataSize (comando de banco de dados)

dataSize

The dataSize command returns the size in bytes for the specified data.

Esse comando está disponível em implantações hospedadas nos seguintes ambientes:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

Importante

This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.

  • 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

O comando tem a seguinte sintaxe:

db.runCommand(
{
dataSize: <string>,
keyPattern: <document>,
min: <document>,
max: <document>,
estimate: <boolean>
}
)

O comando utiliza os seguintes campos:

Campo
Tipo
Descrição

dataSize

string

O nome da coleção de destino.

keyPattern

documento

Opcional. O principal padrão da coleção a ser examinado.

The collection must have an index with the corresponding pattern. Otherwise dataSize returns an error message.

min

documento

Opcional. O limite inferior do intervalo de chaves a ser examinado.

max

documento

Opcional. O limite superior do intervalo de chaves a ser examinado.

estimate

booleano

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. The collection's average object size is obtained from the avgObjSize field in the output of the collStats command.

O padrão é falso.

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 } })

Isso retorna um documento com o tamanho em bytes de todos os documentos correspondentes. Substitua database.collection pelo banco de dados e pela coleção da sua implantação.

The amount of time required to return dataSize depends on the amount of data in the collection.