In attempting to download a large batch of data from Postgres 9.3 in C via libpq's PQexec
, I'm wondering if there's a way to stream the result set from the server. From watching top, I can see my memory utilization increasing by roughly the expected result set size when I call PQexec
. I want to iterate over the results and "throw away" the results after I've processed them to keep the memory utilization on the processing node down. I couldn't find any mention of such behavior in the docs. Something like psycopg2's fetchmany would be ideal.
Is the only way to "stream" results from libpq by rewriting the query to run in batches?