Get AsNoTracking of paging and use AsNoTracking .
Test code
static void Main(string[] args) { var sw = new Stopwatch(); sw.Start(); using (var context = new MyEntities()) { var query = (from organizations in context.LargeSampleTable.AsNoTracking() where organizations.ErrorID != null orderby organizations.ErrorID select organizations);
Test result:
Reduced memory consumption: 96%
Reduced lead time: 50%
Interpretation
AsNoTracking provides the benefits of using memory for obvious reasons; we donโt need to maintain references to objects when we load them into memory. GC objects are ligated almost immediately. The combination of lazy evaluation and AsNoTracking, and there is no need for paging, and the destruction of the context may be delayed.
Although this is the only test, the large number of lines and the exclusion of most external factors make this a good representation for the general case.
P.Brian.Mackey
source share