Does streaming large result sets with NHibernate actually work?

advertisements

I'm using the method that ayende proposed here:

http://ayende.com/Blog/archive/2010/06/27/nhibernate-streaming-large-result-sets.aspx

on SQL Server 2005 with NHibernate 3.0.

My tests (trying to stream a result set with 10,000,000 items) indicate that the results are not being streamed (it appears the entire result set is loaded into memory first).

How can I get this to work? I will accept any solution that permits streaming of result sets in NHibernate, it doesn't have to be exactly ayende's solution.


Ayende says this:

We still have the problem of memory consumption, though. The session will keep track of all the loaded objects, and if we load a lot of data, it will eventually blow out with an out of memory exception.

This is likely to be the cause. Did you ensure that the session does not track the objects? Try selecting not entities but some member of them to test this.