发布于 2015-09-14 15:15:54 | 188 次阅读 | 评论: 0 | 来源: 网络整理
MongoDB can report data that reflects the current state of the “active” database. In this context “database,” refers to a single MongoDB database. To run dbStats issue this command in the shell:
db.runCommand( { dbStats: 1 } )
The mongo shell provides the helper function db.stats(). Use the following form:
db.stats()
The above commands are equivalent. Without any arguments, db.stats() returns values in bytes. To convert the returned values to kilobytes, use the scale argument:
db.stats(1024)
Or:
db.runCommand( { dbStats: 1, scale: 1024 } )
注解
Because scaling rounds values to whole numbers, scaling may return unlikely or unexpected results.
The above commands are equivalent. See the dbStats database command and the db.stats() helper for the mongo shell for additional information.
Contains the name of the database.
Contains a count of the number of collections in that database.
Contains a count of the number of objects (i.e. documents) in the database across all collections.
The average size of each document in bytes. This is the dataSize divided by the number of documents.
The total size of the data held in this database including the padding factor. The scale argument affects this value. The dataSize will not decrease when documents shrink, but will decrease when you remove documents.
The total amount of space allocated to collections in this database for document storage. The scale argument affects this value. The storageSize does not decrease as you remove or shrink documents.
Contains a count of the number of extents in the database across all collections.
Contains a count of the total number of indexes across all collections in the database.
The total size of all indexes created on this database. The scale arguments affects this value.
The total size of the data files that hold the database. This value includes preallocated space and the padding factor. The value of fileSize only reflects the size of the data files for the database and not the namespace file.
The scale argument affects this value.
The total size of the namespace files (i.e. that end with .ns) for this database. You cannot change the size of the namespace file after creating a database, but you can change the default size for all new namespace files with the nssize runtime option.
也可以参考
The nssize option, and Maximum Namespace File Size