
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
Get database data size in MongoDB?
To get the database data size in MongoDB, you can use stats() method. The syntax is as follows −
db.stats();
Let us use the database with the name ‘test’.
Now, check the current database with the help of the following query −
> db;
The following is the output −
test
Here is the query to get database data size in MongoDB −
> db.stats()
The following is the output −
{ "db" : "test", "collections" : 114, "views" : 0, "objects" : 391, "avgObjSize" : 83.0076726342711, "dataSize" : 32456, "storageSize" : 3211264, "numExtents" : 0, "indexes" : 120, "indexSize" : 2494464, "fsUsedSize" : 126172377088, "fsTotalSize" : 199229435904, "ok" : 1 }
Switch to the database ‘sample’. The query is as follows −
> use sample; switched to db sample
Let us check the currently used database name using db command. The query is as follows −
> db;
The following is the output −
Sample
Let us check the database ‘sample’ data size in MongoDB. The query is as follows −
> db.stats();
The following is the output −
{ "db" : "sample", "collections" : 25, "views" : 0, "objects" : 67, "avgObjSize" : 85.32835820895522, "dataSize" : 5717, "storageSize" : 626688, "numExtents" : 0, "indexes" : 24, "indexSize" : 610304, "fsUsedSize" : 126173016064, "fsTotalSize" : 199229435904, "ok" : 1 }
- Related Articles
- Get the storage size of a database in MongoDB?
- Get the real document BSON size in MongoDB?
- Get the size of a collection in MongoDB using conditions?
- Get Distinct Values with Sorted Data in MongoDB?
- Get the size of all the documents in a MongoDB query?
- How to get embedded data in a MongoDB document?
- How to get data of array intersection in MongoDB?
- How to get the size of the tables of a MySQL database?
- How to get specific data in different formats with MongoDB?
- How to get the equivalent for SELECT column1, column2 FROM tbl in MongoDB Database?
- Querying internal array size in MongoDB?
- Find largest document size in MongoDB?
- How to increase varchar size of an existing column in a database without breaking existing data in MySQL?
- Selecting database inside the JS in MongoDB?
- How to drop a database in MongoDB?

Advertisements