Re: libpq - lack of support to set the fetch size
| От | Daniel Verite |
|---|---|
| Тема | Re: libpq - lack of support to set the fetch size |
| Дата | |
| Msg-id | 5699fc18-f65e-43b2-b73e-6c72ef2d7b3d@mm обсуждение исходный текст |
| Ответ на | Re: libpq - lack of support to set the fetch size (matshyeq <matshyeq@gmail.com>) |
| Ответы |
Re: libpq - lack of support to set the fetch size
|
| Список | pgsql-general |
matshyeq wrote:
> The only solution is CURSOR based which I find an awkward low level hack
> comparing to elegant option supported by native library.
That's not the only solution, even with the current DBD::Pg
you could do:
$dbh->do("COPY (sql-squery) TO STDOUT");
my $data;
while ($dbh->pg_getcopydata($data) >= 0) {
# process $data
}
The results would be streamed as opposed to being accumulated in
memory. Also COPY is optimized for high performance.
The drawback is you'd have to parse $data according to the
specific rules of the COPY format, which may be easy or
not-so-easy depending on the actual data, numeric or text
or other, whether it has NULLs, backslashes and so on.
Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org
В списке pgsql-general по дате отправления: