定義
dataSizeThe
dataSizecommand returns the size in bytes for the specified data.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
重要
This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
このコマンドの構文は、次のとおりです。
db.runCommand( { dataSize: <string>, keyPattern: <document>, min: <document>, max: <document>, estimate: <boolean> } )
コマンドフィールド
このコマンドは、次のフィールドを使用します。
フィールド | タイプ | 説明 |
|---|---|---|
| string | ターゲット コレクションの名前。 |
| ドキュメント | 任意。 調べるコレクションのキー パターン。 The collection must have an index with the corresponding pattern. Otherwise |
| ドキュメント | 任意。 検査するキー範囲の下限。 |
| ドキュメント | 任意。 検査するキー範囲の上限。 |
| ブール値 | Optional. When デフォルトは 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 } })
これにより、一致するすべてのドキュメントのサイズがバイト単位のドキュメントが返されます。 database.collectionを配置のデータベースとコレクションに置き換えます。
The amount of time required to return dataSize depends on the amount of data in the collection.