帝王 发表于 2016-12-2 07:29:43

mongo delete data

  mongo中和普通的sql一样提供了delete接口,不过针对delete有些不一样的是,被删除的数据磁盘空间不会立即释放,而是会重用
  见 http://www.mongodb.org/display/DOCS/Excessive+Disk+Space
Deleted Space
  MongoDB maintains deleted lists of space within the datafiles when objects or collections are deleted.  This space is reused but never freed to the operating system.
  To compact this space, run db.repairDatabase()from the mongo shell
http://www.mongodb.org/images/icons/emoticons/warning.gifthis operation will block and is slow.
  When testing and investigating the size of datafiles, if your data is just test data, use db.dropDatabase()to clear all datafiles and start fresh.
  同时针对想释放空间的用户可以看以下2篇文章的讨论
  MongoDB data remove - reclaim diskspace
  http://stackoverflow.com/questions/5518581/mongodb-data-remove-reclaim-diskspace
  Auto compact the deleted space in mongodb
  http://stackoverflow.com/questions/4555938/auto-compact-the-deleted-space-in-mongodb/4560096#4560096
页: [1]
查看完整版本: mongo delete data