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.