Managed Esent - quicker way to read data?

352 Views Asked by At

Using the Managed Esent interface to read data from a table. I am doing this with (pseudo):

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);
        }
    }
}

I am interested in data from three columns only, which is around 4,000 rows. However, the table itself is 1,800,000 rows. Hence this approach is very slow to just read the data I want as I need to read all 1,800,000 rows. Is there a quicker way?

1

There are 1 best solutions below

0
Martin Chisholm On

There are many things you can do. Here are a few things off the top of my head:

  • Set the minimum cache size SystemParameters.CacheSizeMin. The default cache sizing algorithm is a bit conservative sometimes.
  • Also set OpenTableGrbit.Squential when opening your table. This helps a little bit with prefetching.
  • Use Api.RetrieveColumns to retrieve the three values at once. This reduces the number of calls/pinvokes you'll do.

-martin