我的用例支持上限集合。因此,尝试将现有的无上限集合转换或复制到上限集合。转换/复制成功。但问题是没有足够的记录作为原始包含。
无上限收藏:
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
}
运行命令转换为上限:
db.runCommand({convertToCapped:'com.bigd.raw', size:100000})
封顶系列:
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
}
这里的计数已减少到 293,而原来的计数为 84536。
mongodump
on uncapped 和mongorestore
创建 capped collection( db.createCollection("com.bigd.raw", {capped : true, size :100000})
)也是如此。
使用 mongov3.0.7
帮助表示赞赏。