-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: manual
-
Labels:
-
Environment:MongoDB V2.6.4 64bits, Windows 7 64bits
*Location*: http://docs.mongodb.org/manual/reference/command/cloneCollectionAsCapped/#dbcmd.cloneCollectionAsCapped
*User-Agent*: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
*Referrer*: http://docs.mongodb.org/manual/reference/command/nav-administration/
*Screen Resolution*: 1920 x 1080
*repo*: docs
*source*: reference/command/cloneCollectionAsCapped
MongoDB V2.6.4 64bits, Windows 7 64bits *Location*: http://docs.mongodb.org/manual/reference/command/cloneCollectionAsCapped/#dbcmd.cloneCollectionAsCapped *User-Agent*: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36 *Referrer*: http://docs.mongodb.org/manual/reference/command/nav-administration/ *Screen Resolution*: 1920 x 1080 *repo*: docs *source*: reference/command/cloneCollectionAsCapped
At the bottom of this page
(http://docs.mongodb.org/manual/reference/command/cloneCollectionAsCapped/#clonecollectionascapped)
has below descriptions:
If the capped size specified for the new collection is smaller than the size of the original uncapped collection, then MongoDB will begin overwriting earlier documents in insertion order, which is first in, first out (e.g “FIFO”).
Then I tried below:
> db.a.find() { "_id" : ObjectId("541a400220086dae8eb095ba"), "b" : 1 } { "_id" : ObjectId("541a4463668ac6bf3d1da31d"), "a$a" : 1 } > db.a.stats() { "ns" : "test.a", "count" : 2, "size" : 92, "avgObjSize" : 46, "storageSize" : 4096, "numExtents" : 1, "nindexes" : 1, "lastExtentSize" : 4096, "paddingFactor" : 1, "systemFlags" : 1, "userFlags" : 0, "totalIndexSize" : 8176, "indexSizes" : { "_id_" : 8176 }, "ok" : 1 } > db.runCommand({cloneCollectionAsCapped:"a", toCollection:"aa", size:1}); // capped size specified is 1 byte { "ok" : 1 } > db.aa.find(); { "_id" : ObjectId("541a400220086dae8eb095ba"), "b" : 1 } { "_id" : ObjectId("541a4463668ac6bf3d1da31d"), "a$a" : 1 } > db.aa.stats() { "ns" : "test.aa", "count" : 2, "size" : 72, "avgObjSize" : 36, "storageSize" : 4096, "numExtents" : 1, "nindexes" : 1, "lastExtentSize" : 4096, "paddingFactor" : 1, "systemFlags" : 1, "userFlags" : 0, "totalIndexSize" : 8176, "indexSizes" : { "_id_" : 8176 }, "capped" : true, "max" : NumberLong("9223372036854775807"), "ok" : 1 }
No data have been overwritten in capped collection aa even though I specified a capped size which is smaller than the original collection's.
The size I provided (1 byte) will be converted to ceil-integer times of extent size (4096 bytes). Is it right?