Mongodb释放磁盘空间


 description

清除test表已删除数据的磁盘空间占用

 command

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

 parameter

runCommand(command) :  在当前数据库的上下文中运行命令
{ compact :   <collection name> } :  重写集合中的所有数据和索引并对其进行碎片整理。在WiredTiger数据库上,此命令会将不需要的磁盘空间释放到操作系统

 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.