How to stop NpgsqlDataReader from blocking?
Posted
by Swingline Rage
on Stack Overflow
See other posts from Stack Overflow
or by Swingline Rage
Published on 2010-06-06T06:03:38Z
Indexed on
2010/06/06
6:12 UTC
Read the original article
Hit count: 407
Running the following code against a large PostgreSQL table, the NpgsqlDataReader object blocks until all data is fetched.
NpgsqlCommand cmd = new NpgsqlCommand(strQuery, _conn);
NpgsqlDataReader reader = cmd.ExecuteReader(); // <-- takes 30 seconds
How can I get it to behave such that it doesn't prefetch all the data? I want to step through the resultset row by row without having it fetch all 15 GB into memory at once.
I know there were issues with this sort of thing in Npgsql 1.x but I'm on 2.0. This is against a PostgreSQL 8.3 database on XP/Vista/7. I also don't have any funky "force Npgsql to prefetch" stuff in my connection string. I'm at a complete loss for why this is happening.
© Stack Overflow or respective owner