Table name, Table size, its description, Date it was created in Mongodb

I want to Create a list of tables that take up the most amount of storage, include description of what it is, table name, and size, a date that explains how far back we have historical data in mongodb of the following version 1.8, 2.4, 2.6, 3.2, 3.4.

Format is

Table Name, Table Description, Table Size, Created Date

Is there any query for that which can be run on mongodb irrespective of version.

Hi @Amanullah_Ashraf1,

All of the server versions you listed have been End of Life for at least a few years and some for much longer (MongoDB 1.8 was EOL in September 2012). The initial release dates are also 6 to 11 years ago so this represents a large amount of change in the server product.

However, since you are running basic commands (list databases/collections and get stats) you should be able to connect with a driver or the mongo shell to iterate the collection names and sizes. I expect you’ll have more success using a driver or mongo version matching the latest of your release series (3.4).

I suggest you choose an approach using driver or mongo shell and let us know if you run into any difficulties.

Created Date

MongoDB doesn’t store creation dates for databases or collections. For collections using default ObjectIDs for _id, you could probably infer this by extracting a timestamp from the oldest _id in the collection. For example, in the mongo shell:

> var first ={}).sort({_id:1}).limit(1).next()
> first._id.getTimestamp()


1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.