1

我想向 MongoDB 添加 1,000,000 个文档。我运行这个虚拟代码,

Mongo mongo = null;
mongo = new Mongo("localhost", 27017);

DB db = mongo.getDB("MyTestDB");

System.out.println("Connection was established....");

DBCollection col = db.getCollection("ThirdCollection");

for (int i = 0; i < 100000; i++) {
    BasicDBObject doc = new BasicDBObject("name", "MongoDB "+i)
            .append("type", "database")
            .append("count", 1)
            .append("info",
                    new BasicDBObject("x", 203).append("y", 102));

    col.insert(doc);
}

我看到它只插入了 99,637 个文档。

我是 MongoDB 的新手,可能是优化问题还是其他问题?

谢谢

4

0 回答 0