How DataReader works?

I strongly suspect that the reader reads a batch of results at a time. That’s a lot more efficient than one row at a time (think about the situation where a single row is only a few bytes… you don’t want a network packet per row when it could have retrieved lots of rows in a single packet). It also potentially allows the database to release its internal resources early – if the data reader has read all the results (when there are only a few) it can effectively forget about the query.

I suspect if you try the same type of thing with a query returning lots of results, you’d get the expected exception.

Leave a Comment