How to allocate space in Mongodb


Clear the disk space occupied by the deleted data in the test table


db.runCommand({compact: "test" })


runCommand(command) :   Run a command in the context of the current database
{compact :   <collection name> } :   Rewrite and defragment all data and indexes in the collection. On the WiredTiger database, this command will release unnecessary disk space to the operating system


    "ok" : 1.0
Was this helpful?

I hope to help every developer quickly find the commands they need. Of course, you can also add your own commonly used commands for easy searching.