>> > It looks like $r->child_terminate does what I need. In the case of >> > Postgresql it eats the memory when you execute the query, regardless >> > of whether you actually fetch any results. >> >> That can be worked around, however. By using a cursor, you can specify >> exactly how much data you want at a time: > > DBD::Pg doesn't support cursors. From the DBD::PG manpage:
This is true that DBD::Pg doesn't support cursors, but you can write a pl/pgsql function that returns a cursor reference and implement in this manner: $sth = $dbh->prepare("FETCH ALL FROM $your_ref_cursor"); while($sth->fetch){} pl/perl was just introduced also, but I haven't looked at it enough to know if you could use it to write the function.