一直很好奇mongo执行db.collection.drop之后需不需要优化。
所以先查了官方文档:
drop
引用
http://docs.mongodb.org/manual/reference/command/drop/
The drop command removes an entire collection from a database.
Note that this command also removes any indexes associated with the dropped collection.
drop会连索引一块删除
compact
引用
http://docs.mongodb.org/manual/reference/command/compact/
Rewrites and defragments all data in a collection, as well as all of the indexes on that collection.
compact may increase the total size and number of your data files, especially when run for the first time. However, this will not increase the total collection storage space since storage size is the amount of data allocated within the database files, and not the size/number of the files on the file system.
compact requires up to 2 gigabytes of additional disk space while running. Unlike repairDatabase, compact does not free space on the file system.
compact commands do not replicate to secondaries in a replica set:
Compact each member separately.
Ideally run compact on a secondary. See option force:true above for information regarding compacting the primary.
可见compact是一个collection的磁盘碎片整理,且会block整个数据库
compact会增加mongo的磁盘占用(且需要2G临时空间),而repairDatabase可以free space
compact操作不会传播到secondaries上,需要一个一个操作
repairDatabase
引用
The repairDatabase command checks and repairs errors and inconsistencies with the data storage. The command is analogous to a fsck command for file systems.
Note When using journaling, there is almost never any need to run repairDatabase. In the event of an unclean shutdown, the server will be able restore the data files to a pristine state automatically.
As a side effect, the repairDatabase command will compact the database, as the compact command, and also reduces the total size of the data files on disk. The repairDatabase command will also recreate all indexes in the database.
repairDatabase用来检查和修复错误及数据不一致,与fsck相似
打开journal日志之后几乎没有必要再repariDatabase.
repairDatabase副作用是会compact,重建索引和减少磁盘占用
小结:
所以从文档来看,没有直接必要在删大表之后重新repairDatabase。暂时没找到证据说明repairDatabase之后可以提高性能,只是能够把磁盘空间回收而已
分享到:
相关推荐
MongoVUE简单操作手册,里面有增删查改的一些基本操作,对MONGO的一些学习者有一定帮助。
mongo基础操作命令,增删改查等基础命令。mongo基础操作命令,增删改查等基础命令。
MongoDB 教程 MongoDB 是一个基于分布式文件存储的数据库。由 C++ 语言编写。旨在为 WEB 应用提供可扩展的高性能数据存储解决方案。
mongo group by mapreduce操作指导!
mongo连接工具 mongo连接工具 mongo连接工具 mongo连接工具 mongo连接工具
阿里mongo同步工具mongo-shake
MongoVUE是一个创新的MongoDB桌面应用Windows操作系统,给你一个优雅的、高度可用的GUI界面来使用MongoDB。现在有一个更少的担心在管理你的网络数据。 MongoVUE使其成为一个非常简单的看到并可视化数据。
java操作mongo的小例子
c# furion操作 mongo
mongoVUE.1.6.9.破解文件,解压后覆盖安装目录中的MongoVUE.exe文件 安装文件下载地址:http://www.mongovue.com/downloads/
完全面向对象的mongo封装,maven工程源码,可直接install导出jar包引用,支持基本的增删改查和分页等,使用反射对javaBean实体进行映射,所有方法参数只需要传javaBean就行了,支持带密码连接,即拿即用,无需修改。
Mongo数据库连接工具,带破解批处理文件.3T支持的mongo功能很多
mongo免安装mongo免安装
MongoVUE
mongo客户端mongo客户端mongo客户端mongo客户端mongo客户端
基于spring data mongo 些的 操作mongo的工具api。 让业务开发人员不用去了解mongo的知识
mongo docker 镜像
mongo服务器搭建之后所需的mongo客户端,功能强大,简单易用
Java操作mongo包含lib,增删改查及gridFS操作
安装后将mongovue.exe替换系统安装的mongovue.exe就能免费使用mongovue所有功能。