
- 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
How to reduce MongoDB storage space after deleting large amount of data?
To reduce MongoDB storage space after deleting a large amount of data, you need to use repairDatabase(). Let’s say we are using the database “test”. Following is the query to get to the current database
> db;
This will produce the following output
Test
After deleting large amount of data, this is how you can reduce the storage space of MongoDB
> db.repairDatabase()
This will produce the following output
{ "ok" : 1 }
Here is the screenshot after we implement the above query. This will reduce the storage space:
- Related Articles
- How to auto increment with 1 after deleting data from a MySQL table?
- How to Reclaim your Smart Phone’s Storage Space Quickly
- Reset the primary key to 1 after deleting all the data in MySQL?
- How to optimize a MySQL table after deleting some rows?
- How to add space (" ") after an element using :after selector in CSS?
- Difference between Centralized Data Storage and Distributed Data Storage
- How to redirect website after certain amount of time without JavaScript?
- Implementing MongoDB map-reduce
- MongoDB large collection and slow search? How to fix?
- Deleting all records of a collection in MongoDB Shell?
- How to know which storage engine is used in MongoDB?\n
- How to update after aggregate in MongoDB?
- How to store large data in JavaScript cookies?
- What is data storage? the terms data objects, variables, and constants concerning data storage?
- Program to find longest subarray of 1s after deleting one element using Python

Advertisements