重要
mongosh 方法
This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.
对于数据库命令,请参阅 collStats 命令返回的 storageSize 字段。
如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。
定义
db.collection.storageSize()返回: 分配给该集合以用于文档存储的总存储量(以字节为单位)。
如果集合数据经过压缩 (
default for WiredTiger),则存储大小将反映压缩后的大小,并且可能小于db.collection.dataSize()返回的值。要在副本集成员上运行,
collStats操作需要成员处于PRIMARY或SECONDARY状态。如果节点处于其他状态,如STARTUP2,则操作错误。
兼容性
此方法可用于以下环境中托管的部署:
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
注意
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本