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 ...

Get MongoDB Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.