With following command, I can get the data size of a specific collection:
db.collection.dataSize()
How do I get the datasize of a database?
The maximum BSON document size is 16MB or 16777216 bytes. All conversions should use base-2 scale, e.g. 1024 kilobytes = 1 megabyte.
MongoDB: db. stats() method is used to return a document that reports on the state of the current database.
Does MongoDB handle caching? Yes. MongoDB keeps most recently used data in RAM. If you have created indexes for your queries and your working data set fits in RAM, MongoDB serves all queries from memory.
Ad-hoc queries are the queries not known while structuring the database. So, MongoDB provides ad-hoc query support which makes it so special in this case. Ad-hoc queries are updated in real time, leading to an improvement in performance.
Use following command at mongoshell:
db.stats()
Output should be like this:
{ "collections" : 3, "objects" : 80614, "dataSize" : 21069700, "storageSize" : 39845376, "numExtents" : 9, "indexes" : 2, "indexSize" : 6012928, "ok" : 1 }
See more diagnostic command here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With