score:1

Accepted answer

"LINQ" includes LINQ to Objects, LINQ to SQL, etc. You can certainly query in memory, but maybe you should wait until you've done a performance analysis before optimizing. You may optimize the wrong thing.

score:1

Ad hoc, loading up to 250 megabytes of data into client memory seems not to be such an good idea. If you have it memory, you can use LINQ to Object and save the database roundtrips.

The problem is that your data is hierarchical and you have to fetch one row, examin it, and retrieve the releated rows and this causes so many roundtrips.

You could use lazy loading to retrieve more and more rows into client memory during the runtime of your program and perform more and more queries in memory when the working set stabilizes. But this will only help if rows are accessed multiple times and not only once or twice.

Another solution might be to create recursive views or stored procedure using common table expression that retrieve releate rows up to some distance from a given row.


Related Articles