2017-03-23 80 views
0

使用Managed Esent接口從表中讀取數據。我用(僞)做這個:託管Esent - 更快的方式來讀取數據?

List<ColumnInfo> columns; //Three columns to be read 

using (var table = Table(session,DBID,"tablename",OpenTableGrbit.Readonly)) 
{ 
    while (Api.TryMoveNext(session, table)) 
    { 
     foreach (ColumnInfo col in columns) 
     { 
      string data = GetFormattedColumnData(session,table,col); 
     } 
    } 
} 

我只對三列數據感興趣,大約有4000行。但是,表格本身是180,000行。因此,這種方法讀取我想要的數據非常緩慢,因爲我需要讀取所有1,800,000行。有更快的方法嗎?

回答

0

你可以做很多事情。這裏有幾件事是我的頭頂:

  • 設置最小緩存大小SystemParameters.CacheSizeMin。有時默認的緩存大小調整算法有點保守。
  • 還設置OpenTableGrbit.Squential當您打開您的表。這有助於預取。
  • 使用Api.RetrieveColumns一次檢索三個值。這樣可以減少您要做的電話/ pinvokes的數量。

-martin

相關問題