0

My use-case supports capped collections. So, trying to convert or copy existing uncapped collection to capped collection. Conversion/Copy are successful. But the problem is there are no enough records as original contain.

Uncapped Collection:

db.com.bigd.raw.stats()
{
        "ns" : "dbname.com.bigd.raw",
        "count" : 84536,
        "size" : 41929856,
        "avgObjSize" : 496,
        "numExtents" : 9,
        "storageSize" : 58441728,
        "lastExtentSize" : 20643840,
        "paddingFactor" : 1,
        "paddingFactorNote" : "paddingFactor is unused and unmaintained in 3.0. It remains hard coded to 1.0 for compatibility only.",
        "userFlags" : 1,
        "capped" : false,
        "nindexes" : 1,
        "totalIndexSize" : 3515680,
        "indexSizes" : {
                "_id_" : 3515680
        },
        "ok" : 1

}

Running command to convert as capped:

db.runCommand({convertToCapped:'com.bigd.raw', size:100000})

Capped Collection:

db.com.bigd.raw.stats()
{
        "ns" : "dbname.com.bigd.raw",
        "count" : 293,
        "size" : 97188,
        "avgObjSize" : 331,
        "numExtents" : 1,
        "storageSize" : 102400,
        "lastExtentSize" : 102400,
        "paddingFactor" : 1,
        "paddingFactorNote" : "paddingFactor is unused and unmaintained in 3.0. It remains hard coded to 1.0 for compatibility only.",
        "userFlags" : 1,
        "capped" : true,
        "max" : NumberLong("9223372036854775807"),
        "maxSize" : 102400,
        "nindexes" : 1,
        "totalIndexSize" : 24528,
        "indexSizes" : {
                "_id_" : 24528
        },
        "ok" : 1
}

The count here has reduced to 293, whereas in original its 84536.

The same happened with mongodump on uncapped and mongorestore to create capped collection(db.createCollection("com.bigd.raw", {capped : true, size :100000})).

Using mongo v3.0.7

Help is appreciated.

srikanth
  • 958
  • 16
  • 37
  • And the problem is...? The capped collection has exactly this meaning: limit to a given size and throw away documents which do not fit using a least-recently-entered algorithm. If you limit the collection to about 0.2% of the original collection, what else did you expect? – mtj Nov 09 '16 at 07:32
  • 1
    @mtj: you mean to say size is just a byte size and not count of documents in the collection. right? Got it. Thanks. – srikanth Nov 09 '16 at 07:43

0 Answers0