将无上限的集合转换或复制到上限

时间:2016-11-09 07:20:35

标签: mongodb mongodump mongorestore capped-collections

我的用例支持上限集合。因此,尝试将现有的无上限集合转换或复制到上限集合。转换/复制成功。但问题是原始包含的记录不足。

无上限收藏:

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在无上限和mongorestore创建上限集合(db.createCollection("com.bigd.raw", {capped : true, size :100000}))时也是如此。

使用mongo v3.0.7

非常感谢帮助。

0 个答案:

没有答案