Re: DBD::Pg/perl question, kind of...

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: DBD::Pg/perl question, kind of...
Дата
Msg-id AFCCBB403D7E7A4581E48F20AF3E5DB2019DAB24@EXADV1.host.magwien.gv.at
обсуждение исходный текст
Ответ на DBD::Pg/perl question, kind of...  (Neal Clark <nclark@securescience.net>)
Ответы Re: DBD::Pg/perl question, kind of...  (Douglas McNaught <doug@mcnaught.org>)
Список pgsql-general
Neal Clark wrote:
> my $sth = $dbh->prepare(qq{SOME_QUERY});
> $sth->execute;
> while (my $href = $sth->fetchrow_hashref) {
>     # do stuff
> }
>
[...]
>
> So with mysql, I can just say $dbh->{'mysql-use-result'} = 1, and
> then it switches so that the fetchrow_hashref calls are actually
> fetching from the database, and I only have one row in memory at a
> time, unless I copy the reference and let it wander off somewhere
> else, or something.
>
> So all I'm really asking is, how does postgre approach the use result/

> store result issue? Can I easily process result sets that are larger
> than memory? And if it handles it similar to mysql, does it also
> cause the same table locking behaviour?

The man page of DBD::Pg says, and my experiments with tcpdump confirm:

   RowCacheSize  (integer)
   Implemented by DBI, not used by this driver.

And more:

   Cursors

   Although PostgreSQL has a cursor concept, it has not been used in the
   current implementation. Cursors in PostgreSQL can only be used inside
a
   transaction block. Because only one transaction block at a time is
   allowed, this would have implied the restriction not to use any
nested
   "SELECT" statements. Hence the "execute" method fetches all data at
   once into data structures located in the front-end application. This
   approach must to be considered when selecting large amounts of data!

So there is no automatic way of handling it.

You will probably have to consider it in your code and use
SELECT-Statements
with a LIMIT clause.

Yours,
Laurenz Albe

В списке pgsql-general по дате отправления:

Предыдущее
От: Neal Clark
Дата:
Сообщение: DBD::Pg/perl question, kind of...
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: %tsearch gendict snowball spanish