1
考慮以下代碼輸出時間爲3056
(約3秒)。性能差
因此,我使用MongoDb文檔推薦的代碼。
MongoClient mongo = new MongoClient();
var server = mongo.GetServer();
MongoDatabase db = server.GetDatabase("tutorial");
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
using (server.RequestStart(db))
{
MongoCollection<BsonDocument> collection = db.GetCollection<BsonDocument>("books");
for (int i = 0; i < 100000; i++)
{
var nested = new BsonDocument
{
{"name", "John Doe"},
};
collection.Insert(nested);
}
}
stopwatch.Stop();
Console.WriteLine(stopwatch.ElapsedMilliseconds);
Console.ReadLine();
當上述代碼運行的輸出時間是14225
(大約10至14秒我的PC上)。 爲什麼我在新版本的mongoDb上重構代碼後得到這樣的性能時間。我錯過了什麼?
這正是我正在尋找與WriteConcern.Unacknowledged集我得到同樣的performance.thank你。 –