Para agentes de IA: hay un índice de documentación disponible en https://www.mongodb.com/es/docs/llms.txt — versiones en markdown de todas las páginas están disponibles agregando .md a cualquier ruta URL.
Docs Menu

dataSize (comando de base de datos)

dataSize

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

Este comando está disponible en implementaciones alojadas en los siguientes entornos:

  • MongoDB Atlas: El servicio totalmente gestionado para implementaciones de MongoDB en la nube

Importante

Este comando no es compatible con los clústeres M0 y Flex. Para obtener más información, consulta Comandos no compatibles.

  • MongoDB Enterprise: La versión basada en suscripción y autogestionada de MongoDB

  • MongoDB Community: La versión de MongoDB con código fuente disponible, de uso gratuito y autogestionada.

El comando tiene la siguiente sintaxis:

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

El comando toma los siguientes campos:

Campo
Tipo
Descripción

dataSize

string

El nombre de la colección objetivo.

keyPattern

Documento

opcional. El patrón clave de la colección para examinar.

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

min

Documento

opcional. El límite inferior del rango clave a examinar.

max

Documento

opcional. El límite superior del rango de claves que se examinará.

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.

Se configura por defecto en false.

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

Esto devuelve un documento con el tamaño en bytes para todos los documentos coincidentes. Reemplace database.collection por la base de datos y colección de tu implementación.

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