Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-4061

Comment on: "manual/reference/command/cloneCollectionAsCapped.txt"

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • v1.3.12
    • None
    • manual

    Description

      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?

      Attachments

        Activity

          People

            andrew.aldridge@mongodb.com Andrew Aldridge
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              9 years, 18 weeks, 5 days ago