© 2012 10gen, the MongoDB Company
Authors: Andrea Lattuada
The commands used by this tool are currently EXPERIMENTAL and UNSUPPORTED.
Storage-viz is a suite of web-based visualizers that leverage new database commands: they make it easier to understand and analyze MongoDB storage and btree layout.
The storageDetails
command will aggregate statistics related to the
storage layout (when invoked with analyze: "diskStorage"
) or the percentage
of pages currently in RAM (when invoked with analyze: "pagesInRAM"
) for the
specified collection, extent or part of extent.
The indexStats
command provides detailed and aggregate information and
statistics for the underlying btree of a particular index.
Stats are aggregated for the entire tree, per-depth and, if requested through
the expandNodes
option, per-subtree.
Both commands take a global READ_LOCK and will page in all the extents or btree
buckets encountered: this will have adverse effects on server performance.
The commands should never be run on a primary and will cause a secondary to
fall behind on replication. diskStorage
when run with
analyze: "pagesInRAM"
is the exception as it typically returns rapidly and
may only page in extent headers.
To use the commands and visualizers you need a recent MongoDB Nightly build.
You can enable the experimental commands with
--enableExperimentalStorageDetailsCmd
or
--enableExperimentalIndexStatsCmd
NOTE: running mongod with these options is unsafe and not advisable for production servers.
If you'd like to run the commands directly within the shell, helpers are available.
Json output:
db.collection.diskStorageStats({...})
db.collection.pagesInRAM({...})
db.collection.indexStats({index: "index name", ...})
Their counterparts providing human-readable output follow.
db.collection.getDiskStorageStats({...})
db.collection.getPagesInRAM({...})
db.collection.getIndexStats({...})
To use the visualizers the server needs to be started with the --rest --jsonp
command
line flags.
NOTE: running mongod with these options is unsafe and not advisable for
production servers.
Moreover, --rest --jsonp
allows anyone on the same network as the server
to invoke commands and query or modify data.
The visualizers provide a nicer graphical representation but are very early stage and have only been tested in Chrome. The source code for them is available in this repository.
https://utaal.github.com/mongovis/diskStorageStats.html displays storage layout and usage.
https://utaal.github.com/mongovis/indexStats.html shows statistics related to the indexing btrees.
https://utaal.github.com/mongovis/pagesInRAM.html reports which parts of a collection is currently in ram.
If you'd like to report a bug or request a new feature, please file an issue on our github repository (you must be logged into github to do this):