2012-03-22 35 views
1

我已經從NuGet安裝了最新的嵌入式二進制文件,並使用此代碼來存儲'產品'poco。過了一會兒,該進程就會因OutOfMemoryException而死亡。是否將這些數據存儲在Raven的範圍之外?如何向RavenDB添加幾百萬個文檔 - 嵌入式

謝謝。 斯蒂芬

var store = new EmbeddableDocumentStore { DataDirectory = @"C:\temp\ravendata", UseEmbeddedHttpServer = true }; 
store.Initialize(); 

using (var session = store.OpenSession()) 
{ 
    foreach (var item in Parsers.GetProducts().ToList()) 
    { 
     session.Store(item); 

    } 
    session.SaveChanges(); 
    //var rdbList = session.Query<Product>().ToList(); 
} 


[Serializable] 
public class Product 
{ 
    public decimal ProductId { get; set; } 

    public string ItemNum { get; set; } 

    public string ProductName { get; set; } 

    public string BrandName { get; set; } 

    public string UOM { get; set; } 

    public string AveWeight { get; set; } 

    public string CasePack { get; set; } 

    public string PackageRemarks { get; set; } 

    public decimal Price { get; set; } 

    public string SupplierName { get; set; } 

    public string Url { get; set; } 

    public bool IsSpecialOrderItem { get; set; } 

    public bool IsSpecialPriceItem { get; set; } 

    public bool IsRebateItem { get; set; } 

    public bool IsTieredPricingItem { get; set; } 

    public bool IsOfflineSupplierItem { get; set; } 

    public string Catalog { get; set; } 

    public decimal CatalogId { get; set; } 

    public decimal CategoryId { get; set; } 

    public decimal PriceGroupId { get; set; } 

    public decimal OffineSupplierId { get; set; } 

    public string ManufactureName { get; set; } 

    public string ManufactureNum { get; set; } 

    public string Upc { get; set; } 

    public string Info { get; set; } 

    public string INFO2 { get; set; } 
} 

回答

2

如何一批大你在幹什麼?看起來人們擁有256批次的成功。似乎更多導致超時和內存異常。

*編輯:它聽起來像它也建議每個批次新會話,以便不會保持會話打開太長,這可能會導致超時錯誤。

+0

亞當,沒有批次..這可能是一個問題..我會在文檔中查找批次..謝謝。 – 2012-03-22 22:47:04

+0

亞當,你和丹尼爾一樣正確(雖然有點冗長),所以我給你一個正確的答案。我能夠從Demis ServiceStack測試代碼中獲取代碼https://github.com/ServiceStack/ServiceStack.Benchmarks/blob/master/src/NoSqlPerformance/NoSqlPerformance.ConsoleApp/Program.cs – 2012-03-23 01:37:31

2

不,RavenDB對於這個數據量是完全正確的。除非您不需要RunInMemoryEmbeddedDocumentStore與獨立服務器幾乎相同,只是沒有http開銷並直接從客戶端訪問數據庫。

鑑於您的代碼,您希望確保您批量存儲文檔,例如,每個會話1024個。你想確定的另一件事是,你的GetProducts()方法返回一個IEnumerable,並以適當的ETL方式產生項目。

+1

我正在閱讀本文,因爲它現在屬於我已添加到數據庫的文檔..http://daniellang.net/searching-on-string-properties-in-ravendb/謝謝 – 2012-03-23 03:13:48

相關問題