VLAN学习笔记大全
2008-12-30 03:09
323 查看
一直很好奇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之后可以提高性能,只是能够把磁盘空间回收而已
所以先查了官方文档:
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之后可以提高性能,只是能够把磁盘空间回收而已
相关文章推荐
- VLAN学习笔记大全(2)
- VLAN学习笔记大全
- VLAN学习笔记大全1
- VLAN学习笔记大全(3)
- VLAN学习笔记大全
- VLAN学习笔记大全
- VLAN学习笔记大全(1)
- [学习笔记]android:系列样式大全
- CCNA学习笔记六--VLAN
- 学习笔记问题大全【整理】1 C++
- vlan学习笔记
- VLAN 学习笔记
- Html5学习标签个人笔记大全
- linux学习笔记2----userd命令大全
- MySQL语法大全_自己整理的学习笔记
- lamp兄弟连linux学习笔记-linux常用命令大全(思维导图)
- 黑马程序员 学习笔记——SQL查询语句大全
- Windows SDK学习笔记----Combo Box 用法大全(Backer原创)
- java关于流的学习笔记大全,包含全部流的概念及用法