Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

database dataSize in mongodb

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?

like image 202
JuanPablo Avatar asked May 30 '11 15:05

JuanPablo


People also ask

What is data size in MongoDB?

The maximum BSON document size is 16MB or 16777216 bytes. All conversions should use base-2 scale, e.g. 1024 kilobytes = 1 megabyte.

What is DB stats in MongoDB?

MongoDB: db. stats() method is used to return a document that reports on the state of the current database.

Can we use MongoDB for caching?

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.

Does MongoDB allow ad hoc queries?

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.


1 Answers

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.

like image 154
Andrew Orsich Avatar answered Sep 23 '22 21:09

Andrew Orsich