发布于 2015-09-14 15:00:56 | 167 次阅读 | 评论: 0 | 来源: 网络整理

collMod

2.2 新版功能.

collMod makes it possible to add flags to a collection to modify the behavior of MongoDB. In the current release the only available flag is usePowerOf2Sizes. The command takes the following prototype form:

db.runCommand( {"collMod" : <collection> , "<flag>" : <value> } )

In this command substitute <collection> with the name of a collection in the current database, and <flag> and <value> with the flag and value you want to set.

usePowerOf2Sizes

The usePowerOf2Sizes flag changes the method that MongoDB uses to allocate space on disk for documents in this collection. By setting usePowerOf2Sizes, you ensure that MongoDB will allocate space for documents in sizes that are powers of 2 (e.g. 4, 8, 16, 32, 64, 128, 256, 512...8388608). With usePowerOf2Sizes MongoDB will be able to more effectively reuse space.

usePowerOf2Sizes is useful for collections where you will be inserting and deleting large numbers of documents to ensure that MongoDB will effectively use space on disk.

Example

To enable usePowerOf2Sizes on the collection named products, use the following operation:

db.runCommand( {collMod: "products", usePowerOf2Sizes : true })

To disable usePowerOf2Sizes on the collection products, use the following operation:

db.runCommand( { collMod: "products", "usePowerOf2Sizes": false })

警告

在 2.2.1 版更改: usePowerOf2Sizes now supports documents larger than 8 megabytes. If you enable usePowerOf2Sizes you must use at least version 2.2.1.

usePowerOf2Sizes only affects subsequent allocations caused by document insertion or record relocation as a result of document growth, and does not affect existing allocations.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务