Definición
dataSizeThe
dataSizecommand returns the size in bytes for the specified data.
Compatibilidad
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.
Sintaxis
El comando tiene la siguiente sintaxis:
db.runCommand( { dataSize: <string>, keyPattern: <document>, min: <document>, max: <document>, estimate: <boolean> } )
Campos de comandos
El comando toma los siguientes campos:
Campo | Tipo | Descripción |
|---|---|---|
| string | El nombre de la colección objetivo. |
| Documento | opcional. El patrón clave de la colección para examinar. The collection must have an index with the corresponding pattern. Otherwise |
| Documento | opcional. El límite inferior del rango clave a examinar. |
| Documento | opcional. El límite superior del rango de claves que se examinará. |
| booleano | Optional. When Se configura por defecto en false. |
Ejemplo
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.