dbStats

rs_main:PRIMARY> db.runCommand({ dbStats: 1, scale: 1 })

{

"db" : "test",

"collections" : 4,

"objects" : 12,

"avgObjSize" : 56.333333333333336,

"dataSize" : 676,

"storageSize" : 20480,

"numExtents" : 4,

"indexes" : 3,

"indexSize" : 24528,

"fileSize" : 201326592,

"nsSizeMB" : 16,

"dataFileVersion" : {

"major" : 4,

"minor" : 5

},

"ok" : 1

}


dbStats


Definition


dbStats

The dbStats command returns storage statistics for a given database. The command takes the following syntax:


{ dbStats: 1, scale: 1 }

The values of the options above do not affect the output of the command. The scale option allows you to specify how to scale byte values. For example, a scale value of 1024 will display the results in kilobytes rather than in bytes:


{ dbStats: 1, scale: 1024 }

NOTE

Because scaling rounds values to whole numbers, scaling may return unlikely or unexpected results.

The time required to run the command depends on the total size of the database. Because the command must touch all data files, the command may take several seconds to run.


In the mongo shell, the db.stats() function provides a wrapper around dbStats.


Output


dbStats.db

Contains the name of the database.


dbStats.collections

Contains a count of the number of collections in that database.


dbStats.objects

Contains a count of the number of objects (i.e. documents) in the database across all collections.


dbStats.avgObjSize

The average size of each document in bytes. This is the dataSize divided by the number of documents.


dbStats.dataSize

The total size in bytes 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.


dbStats.storageSize

The total amount of space in bytes 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.


dbStats.numExtents

Contains a count of the number of extents in the database across all collections.


dbStats.indexes

Contains a count of the total number of indexes across all collections in the database.


dbStats.indexSize

The total size in bytes of all indexes created on this database. The scale arguments affects this value.


dbStats.fileSize

The total size in bytes 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.


dbStats.nsSizeMB

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.


storage.nsSize

Type: integer

Default: 16

Specifies the default size for namespace files, which are files that end in .ns. Each collection and index counts as a namespace.

Use this setting to control size for newly created namespace files. This option has no impact on existing files. The maximum size for a namespace file is 2047 megabytes. The default value of 16 megabytes provides for approximately 24,000 namespaces.

The storage.nsSize option is available only for mongod.


SEE ALSO

The nsSize option, and Maximum Namespace File Size

dbStats.dataFileVersion

New in version 2.4.


Document that contains information about the on-disk format of the data files for the database.


dbStats.dataFileVersion.major

New in version 2.4.


The major version number for the on-disk format of the data files for the database.


dbStats.dataFileVersion.minor

New in version 2.4.


The minor version number for the on-disk format of the data files for the database.


本文出自 “传奇库子” 博客,请务必保留此出处http://chason.blog.51cto.com/9078447/1606719

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。