How to allocate space in Mongodb


 description

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

 command

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

 parameter

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

 result

{
    "ok" : 1.0
}

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.