2016-09-21 67 views
1

我創建的MongoDB數據庫在Linux服務器(標準D2 V2(2芯,7 GB內存))非常緩慢。 MongoDB是在Windows Azure平臺上Azure平臺

我測試數據插入到數據庫與下面的代碼。但結果不好..! 47秒插入100.000記錄非常糟糕。問題是什麼? enter image description here

代碼爲插入到MongoDB的在Azure上(Linux的虛擬機 - 標準D2 V2(2芯,7 GB內存))

string connectionString = "mongodb://root:[email protected]:27017"; 
var client = new MongoClient(connectionString); 
var database = client.GetDatabase("testdb"); 
var collection = database.GetCollection<Item>("foo"); 
var documents = Enumerable.Range(1, 100000).Select(i => new Item 
{ 
    Address = "Address " + i, 
    City = "City " + i, 
    Index = i + 1, 
    Name = "Name " + i, 
    Status = i % 2 == 0, 
    Surname = "Surname " + i, 
    Title = "Title " + i, 
    Town = "Town " + i 
}); 
var models = documents.Select(s => new InsertOneModel<Item>(s)).ToList(); 
Stopwatch sw = new Stopwatch(); 
sw.Start(); 
var result = collection.BulkWrite(models); 
sw.Stop(); 
Console.WriteLine("Seconds:" + sw.Elapsed.Seconds); 
result.InsertedCount.Dump(); 
collection.Count(p => 1 == 1).Dump(); 
+0

什麼比很慢? –

+0

Sql Server的批量插入速度比MongoDB相同的數據快。 –

+0

你如何在Mongo中插入數據? :D –

回答

0

我的數據文件

+0

嘗試使用DS2系列,該系列將SSD磁盤用於操作系統,或將新SSD磁盤附加到現有機器並將日期文件移至其中。 –

+0

好的。我正在嘗試.. –