printCollectionStats() – Return statistics from all collections command
Returns statistics for all collections in the current database.
Syntax diagram
Command parameters
No parameters.
Output
Values for the following properties are returned:
- ns
- The namespace of a specified
collection:
"<JSON namespace>": "<name>.<collection name>"
- count
- Total number of rows in all collections
- size
- Total size of the stored documents in all collections.
- aveObjSize
- Average size of the stored documents, in kilobytes (KB).
- numExtents
- Total number of contiguously allocated data file regions.
- nindexes
- Number of Indexes, including the primary index.
- lastExtentSize
- Size of the last extent allocated.
- paddingFactor
- Automatically-calibrated constant for determining the amount of extra space to be allocated per document container, on disk.
- systemFlags
- Number of flags on the current collection.
- userFlags
- Number of user-set flags on the collection.
- totalIndexSizes
- Total size of indexes on all collections.
- indexSizes
- List of indexes and their sizes on all
collections.
indexSizes[{"<indexname>": <size>}]
Examples
The following example shows the command syntax for returning statistics for all collections in
the current database:
db.printCollectionStats()
The following example shows the
syntax of a value returned from running the printCollectionStats
command:{"ns":"TEST.mycoll","count":8,"size":909312.0,"avgObjSize":111.0,
"numExtents":-1,"nindexes":1,"lastExtentSize":-1,"paddingFactor":-1,"systemFlags":-1,
"userFlags":-1,"totalIndexSizes":-1,"indexSizes":[{"_id_":-1}],"ok":1}
{"ns":"TEST.newC","count":0,"size":-1,"avgObjSize":-1.0,"numExtents":-
1,"nindexes":1,"lastExtentSize":-1,"paddingFactor":-1,"systemFlags":-
1,"userFlags":-1,"totalIndexSizes":-1,"indexSizes":[{"_id_":-
1}],"ok":1,"capped":true,"cappedsize":1000,"cappedrows":5000}