Viewing collection stats
Perhaps one of the interesting statistics from an administrative purpose when it comes to the usage of storage, the number of documents in collection possibly to estimate the future space, and memory requirements based on the growth of the data is to get a high level statistics of the collection.
Getting ready
To find the stats of the collection we need to have a server up and running and a single node is what should be okay. Refer to the Installing single node MongoDB in Chapter 1, Installing and Starting the Server for information on how to start the server. The data on which we would be operating needs to be imported in the database. The steps to import the data are given in the recipe Creating Test Data in Chapter 2, Command-line Operations and Indexes. Once these steps are completed, we are all set to go ahead with this recipe.
How to do it…
- We would be using
postalCodes
collection for viewing the stats. - Open the mongo shell and connect to the running MongoDB...